Merge pull request #2532 from glneto/2444
#2444: Fix wrapped lines search
This commit is contained in:
@@ -0,0 +1,70 @@
|
|||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
make[3]: Entering directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make[3]: Nothing to be done for `libsrc/wrap_curl/CMakeFiles/wrap_curl.dir/build'.
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
[ 0%] /usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
[ 0%] [ 0%] /usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
Built target config_utils
|
||||||
|
[ 0%] make[3]: Entering directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
Built target omega
|
||||||
|
make[3]: Entering directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
cd /home/yan/ssd/searchtrunk/tmp/release && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/yan/ssd/searchtrunk /home/yan/ssd/searchtrunk/projects/protogen/cpp /home/yan/ssd/searchtrunk/tmp/release /home/yan/ssd/searchtrunk/tmp/release/projects/protogen/cpp /home/yan/ssd/searchtrunk/tmp/release/projects/protogen/cpp/CMakeFiles/protogen.dir/DependInfo.cmake --color=
|
||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
Built target morpheus
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make -f libsrc/base/CMakeFiles/base.dir/build.make libsrc/base/CMakeFiles/base.dir/build
|
||||||
|
make[3]: Entering directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make[3]: Nothing to be done for `libsrc/coroutine/CMakeFiles/coroutine.dir/build'.
|
||||||
|
Built target wrap_curl
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
[ 0%] [ 0%] [ 0%] [ 0%] Building CXX object libsrc/image_crop/CMakeFiles/image_crop.dir/src/crop_context.cpp.o
|
||||||
|
cd /home/yan/ssd/searchtrunk/tmp/release/libsrc/image_crop && /opt/rh/devtoolset-7/root/usr/bin/c++ -DGOGO_USE_LIBEVENT2=1 -DGOGO_USE_OPENSSL_SNI=1 -DHAVE_BOOST -DHAVE_GLIBC -DHAVE_MALLOC_TRIM -DHAVE_PREAD -DHAVE_READAHEAD -D_FILE_OFFSET_BITS=64 -D_STAT_LEMM -pipe -Wall -Wextra -Werror=multichar -Wno-deprecated -Wno-unused-parameter -pthread -fPIC -Woverloaded-virtual -Wnon-virtual-dtor -Werror -std=gnu++11 -Wno-unknown-pragmas -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_NO_CXX11_HDR_CODECVT -DMAGICKCORE_QUANTUM_DEPTH=8 -DMAGICKCORE_HDRI_ENABLE=0 -Wno-unused-local-typedefs -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++14 -DCXXHASH128_EXIST -static-libstdc++ -Wno-implicit-fallthrough -Wno-stringop-overflow -O3 -DNDEBUG -DBOOST_UBLAS_NDEBUG -g0 -march=core2 -mssse3 -msse4.1 -I/home/yan/ssd/searchtrunk/tmp/release/__inc -I/home/yan/ssd/searchtrunk/libsrc/image_crop/src -I/home/yan/ssd/searchtrunk/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/boost_1_69_0/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/icu-49.1.2/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/protobuf-3.4.0/include -I/home/yan/ssd/searchtrunk/tmp/release -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/opencv-3.0.0m2/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/dlib-19.7p1/include -Wno-array-bounds -o CMakeFiles/image_crop.dir/src/crop_context.cpp.o -c /home/yan/ssd/searchtrunk/libsrc/image_crop/src/crop_context.cpp
|
||||||
|
Building CXX object libsrc/image_crop/CMakeFiles/image_crop.dir/src/detector.cpp.o
|
||||||
|
Building CXX object libsrc/image_crop/CMakeFiles/image_crop.dir/src/image_crop.cpp.o
|
||||||
|
cd /home/yan/ssd/searchtrunk/tmp/release/libsrc/image_crop && /opt/rh/devtoolset-7/root/usr/bin/c++ -DGOGO_USE_LIBEVENT2=1 -DGOGO_USE_OPENSSL_SNI=1 -DHAVE_BOOST -DHAVE_GLIBC -DHAVE_MALLOC_TRIM -DHAVE_PREAD -DHAVE_READAHEAD -D_FILE_OFFSET_BITS=64 -D_STAT_LEMM -pipe -Wall -Wextra -Werror=multichar -Wno-deprecated -Wno-unused-parameter -pthread -fPIC -Woverloaded-virtual -Wnon-virtual-dtor -Werror -std=gnu++11 -Wno-unknown-pragmas -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_NO_CXX11_HDR_CODECVT -DMAGICKCORE_QUANTUM_DEPTH=8 -DMAGICKCORE_HDRI_ENABLE=0 -Wno-unused-local-typedefs -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++14 -DCXXHASH128_EXIST -static-libstdc++ -Wno-implicit-fallthrough -Wno-stringop-overflow -O3 -DNDEBUG -DBOOST_UBLAS_NDEBUG -g0 -march=core2 -mssse3 -msse4.1 -I/home/yan/ssd/searchtrunk/tmp/release/__inc -I/home/yan/ssd/searchtrunk/libsrc/image_crop/src -I/home/yan/ssd/searchtrunk/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/boost_1_69_0/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/icu-49.1.2/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/protobuf-3.4.0/include -I/home/yan/ssd/searchtrunk/tmp/release -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/opencv-3.0.0m2/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/dlib-19.7p1/include -Wno-array-bounds -o CMakeFiles/image_crop.dir/src/detector.cpp.o -c /home/yan/ssd/searchtrunk/libsrc/image_crop/src/detector.cpp
|
||||||
|
Built target coroutine
|
||||||
|
cd /home/yan/ssd/searchtrunk/tmp/release/libsrc/image_crop && /opt/rh/devtoolset-7/root/usr/bin/c++ -DGOGO_USE_LIBEVENT2=1 -DGOGO_USE_OPENSSL_SNI=1 -DHAVE_BOOST -DHAVE_GLIBC -DHAVE_MALLOC_TRIM -DHAVE_PREAD -DHAVE_READAHEAD -D_FILE_OFFSET_BITS=64 -D_STAT_LEMM -pipe -Wall -Wextra -Werror=multichar -Wno-deprecated -Wno-unused-parameter -pthread -fPIC -Woverloaded-virtual -Wnon-virtual-dtor -Werror -std=gnu++11 -Wno-unknown-pragmas -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_NO_CXX11_HDR_CODECVT -DMAGICKCORE_QUANTUM_DEPTH=8 -DMAGICKCORE_HDRI_ENABLE=0 -Wno-unused-local-typedefs -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++14 -DCXXHASH128_EXIST -static-libstdc++ -Wno-implicit-fallthrough -Wno-stringop-overflow -O3 -DNDEBUG -DBOOST_UBLAS_NDEBUG -g0 -march=core2 -mssse3 -msse4.1 -I/home/yan/ssd/searchtrunk/tmp/release/__inc -I/home/yan/ssd/searchtrunk/libsrc/image_crop/src -I/home/yan/ssd/searchtrunk/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/boost_1_69_0/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/icu-49.1.2/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/protobuf-3.4.0/include -I/home/yan/ssd/searchtrunk/tmp/release -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/opencv-3.0.0m2/include -isystem /home/yan/ssd/searchtrunk/tmp/release/contrib/dlib-19.7p1/include -Wno-array-bounds -o CMakeFiles/image_crop.dir/src/image_crop.cpp.o -c /home/yan/ssd/searchtrunk/libsrc/image_crop/src/image_crop.cpp
|
||||||
|
make[3]: Entering directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make[3]: Nothing to be done for `libsrc/base/CMakeFiles/base.dir/build'.
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make -f projects/protogen/cpp/CMakeFiles/protogen.dir/build.make projects/protogen/cpp/CMakeFiles/protogen.dir/build
|
||||||
|
[ 0%] Built target base
|
||||||
|
In file included from /home/yan/ssd/searchtrunk/include/image_crop/detector.hpp:3:0,
|
||||||
|
from /home/yan/ssd/searchtrunk/libsrc/image_crop/src/detector.cpp:2:
|
||||||
|
/home/yan/ssd/searchtrunk/include/image_crop/crop_context.hpp:6:10: fatal error: opencv2/dnn.hpp: No such file or directory
|
||||||
|
#include <opencv2/dnn.hpp>
|
||||||
|
^~~~~~~~~~~~~~~~~
|
||||||
|
compilation terminated.
|
||||||
|
make[3]: *** [libsrc/image_crop/CMakeFiles/image_crop.dir/src/detector.cpp.o] Error 1
|
||||||
|
make[3]: *** Waiting for unfinished jobs....
|
||||||
|
In file included from /home/yan/ssd/searchtrunk/include/image_crop/image_crop.hpp:3:0,
|
||||||
|
from /home/yan/ssd/searchtrunk/libsrc/image_crop/src/image_crop.cpp:1:
|
||||||
|
/home/yan/ssd/searchtrunk/include/image_crop/crop_context.hpp:6:10: fatal error: opencv2/dnn.hpp: No such file or directory
|
||||||
|
#include <opencv2/dnn.hpp>
|
||||||
|
^~~~~~~~~~~~~~~~~
|
||||||
|
compilation terminated.
|
||||||
|
make[3]: *** [libsrc/image_crop/CMakeFiles/image_crop.dir/src/image_crop.cpp.o] Error 1
|
||||||
|
In file included from /home/yan/ssd/searchtrunk/libsrc/image_crop/src/crop_context.cpp:1:0:
|
||||||
|
/home/yan/ssd/searchtrunk/include/image_crop/crop_context.hpp:6:10: fatal error: opencv2/dnn.hpp: No such file or directory
|
||||||
|
#include <opencv2/dnn.hpp>
|
||||||
|
^~~~~~~~~~~~~~~~~
|
||||||
|
compilation terminated.
|
||||||
|
make[3]: *** [libsrc/image_crop/CMakeFiles/image_crop.dir/src/crop_context.cpp.o] Error 1
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make[2]: *** [libsrc/image_crop/CMakeFiles/image_crop.dir/all] Error 2
|
||||||
|
make[2]: *** Waiting for unfinished jobs....
|
||||||
|
make[3]: Entering directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make[3]: Nothing to be done for `projects/protogen/cpp/CMakeFiles/protogen.dir/build'.
|
||||||
|
make[3]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
/usr/bin/cmake -E cmake_progress_report /home/yan/ssd/searchtrunk/tmp/release/CMakeFiles 63 64 65 66
|
||||||
|
[ 25%] Built target protogen
|
||||||
|
make[2]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release'
|
||||||
|
make[1]: *** [all] Error 2
|
||||||
|
make[1]: Leaving directory `/home/yan/ssd/searchtrunk/tmp/release/projects/projectX'
|
||||||
|
make: *** [install] Error 2
|
||||||
|
yan@yPC:~/ssd/searchtrunk/projects/projectX$
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
import * as puppeteer from 'puppeteer';
|
import * as puppeteer from 'puppeteer';
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
import { ITerminalOptions } from 'xterm';
|
import { ITerminalOptions } from 'xterm';
|
||||||
|
import { readFile } from 'fs';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
const APP = 'http://127.0.0.1:3000/test';
|
const APP = 'http://127.0.0.1:3000/test';
|
||||||
|
|
||||||
@@ -91,7 +93,7 @@ describe('Search Tests', function (): void {
|
|||||||
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
assert.deepEqual(line.substring(selectionPosition.startColumn, selectionPosition.endColumn), 'package.jsonc');
|
assert.deepEqual(line.substring(selectionPosition.startColumn, selectionPosition.endColumn), 'package.jsonc');
|
||||||
});
|
});
|
||||||
it ('Simple Regex', async () => {
|
it('Simple Regex', async () => {
|
||||||
await writeSync('abc123defABCD');
|
await writeSync('abc123defABCD');
|
||||||
await page.evaluate(`window.search.findNext('[a-z]+', {regex: true})`);
|
await page.evaluate(`window.search.findNext('[a-z]+', {regex: true})`);
|
||||||
assert.deepEqual(await page.evaluate(`window.term.getSelection()`), 'abc');
|
assert.deepEqual(await page.evaluate(`window.term.getSelection()`), 'abc');
|
||||||
@@ -106,6 +108,86 @@ describe('Search Tests', function (): void {
|
|||||||
assert.deepEqual(await page.evaluate(`window.search.findNext('abc')`), true);
|
assert.deepEqual(await page.evaluate(`window.search.findNext('abc')`), true);
|
||||||
assert.deepEqual(await page.evaluate(`window.term.getSelection()`), 'abc');
|
assert.deepEqual(await page.evaluate(`window.term.getSelection()`), 'abc');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Regression tests', () => {
|
||||||
|
describe('#2444 wrapped line content not being found', () => {
|
||||||
|
let fixture: string;
|
||||||
|
before(async () => {
|
||||||
|
const rawFixture = await new Promise<Buffer>(r => readFile(resolve(__dirname, '../fixtures/issue-2444'), (err, data) => r(data)));
|
||||||
|
fixture = rawFixture.toString()
|
||||||
|
.replace(/\n/g, '\\n\\r')
|
||||||
|
.replace(/'/g, '\\\'');
|
||||||
|
});
|
||||||
|
it('should find all occurrences using findNext', async () => {
|
||||||
|
await writeSync(fixture);
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
let selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 53, endColumn: 30, endRow: 53 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 76, endColumn: 30, endRow: 76 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 96, endColumn: 30, endRow: 96 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 1, startRow: 114, endColumn: 7, endRow: 114 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 115, endColumn: 17, endRow: 115 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 1, startRow: 126, endColumn: 7, endRow: 126 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 127, endColumn: 17, endRow: 127 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 1, startRow: 135, endColumn: 7, endRow: 135 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 136, endColumn: 17, endRow: 136 });
|
||||||
|
// Wrap around to first result
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findNext('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 53, endColumn: 30, endRow: 53 });
|
||||||
|
});
|
||||||
|
it('should find all occurrences using findPrevious', async () => {
|
||||||
|
await writeSync(fixture);
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
let selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 136, endColumn: 17, endRow: 136 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 1, startRow: 135, endColumn: 7, endRow: 135 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 127, endColumn: 17, endRow: 127 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 1, startRow: 126, endColumn: 7, endRow: 126 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 115, endColumn: 17, endRow: 115 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 1, startRow: 114, endColumn: 7, endRow: 114 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 96, endColumn: 30, endRow: 96 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 76, endColumn: 30, endRow: 76 });
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 24, startRow: 53, endColumn: 30, endRow: 53 });
|
||||||
|
// Wrap around to first result
|
||||||
|
assert.deepEqual(await page.evaluate(`window.search.findPrevious('opencv')`), true);
|
||||||
|
selectionPosition = await page.evaluate(`window.term.getSelectionPosition()`);
|
||||||
|
assert.deepEqual(selectionPosition, { startColumn: 11, startRow: 136, endColumn: 17, endRow: 136 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function openTerminal(options: ITerminalOptions = {}): Promise<void> {
|
async function openTerminal(options: ITerminalOptions = {}): Promise<void> {
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ export interface ISearchOptions {
|
|||||||
incremental?: boolean;
|
incremental?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ISearchPosition {
|
||||||
|
startCol: number;
|
||||||
|
startRow: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ISearchResult {
|
export interface ISearchResult {
|
||||||
term: string;
|
term: string;
|
||||||
col: number;
|
col: number;
|
||||||
@@ -71,17 +76,23 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
|
||||||
|
const searchPosition: ISearchPosition = {
|
||||||
|
startRow,
|
||||||
|
startCol
|
||||||
|
};
|
||||||
|
|
||||||
// Search startRow
|
// Search startRow
|
||||||
let result = this._findInLine(term, startRow, startCol, searchOptions);
|
let result = this._findInLine(term, searchPosition, searchOptions);
|
||||||
|
|
||||||
// Search from startRow + 1 to end
|
// Search from startRow + 1 to end
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
||||||
for (let y = startRow + 1; y < this._terminal.buffer.baseY + this._terminal.rows; y++) {
|
for (let y = startRow + 1; y < this._terminal.buffer.baseY + this._terminal.rows; y++) {
|
||||||
|
searchPosition.startRow = y;
|
||||||
|
searchPosition.startCol = 0;
|
||||||
// If the current line is wrapped line, increase index of column to ignore the previous scan
|
// If the current line is wrapped line, increase index of column to ignore the previous scan
|
||||||
// Otherwise, reset beginning column index to zero with set new unwrapped line index
|
// Otherwise, reset beginning column index to zero with set new unwrapped line index
|
||||||
result = this._findInLine(term, y, 0, searchOptions);
|
result = this._findInLine(term, searchPosition, searchOptions);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -90,7 +101,9 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
// If we hit the bottom and didn't search from the very top wrap back up
|
// If we hit the bottom and didn't search from the very top wrap back up
|
||||||
if (!result && startRow !== 0) {
|
if (!result && startRow !== 0) {
|
||||||
for (let y = 0; y < startRow; y++) {
|
for (let y = 0; y < startRow; y++) {
|
||||||
result = this._findInLine(term, y, 0, searchOptions);
|
searchPosition.startRow = y;
|
||||||
|
searchPosition.startCol = 0;
|
||||||
|
result = this._findInLine(term, searchPosition, searchOptions);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -135,21 +148,26 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
const searchPosition: ISearchPosition = {
|
||||||
|
startRow,
|
||||||
|
startCol
|
||||||
|
};
|
||||||
|
|
||||||
if (incremental) {
|
if (incremental) {
|
||||||
result = this._findInLine(term, startRow, startCol, searchOptions, false);
|
result = this._findInLine(term, searchPosition, searchOptions, false);
|
||||||
if (!(result && result.row === startRow && result.col === startCol)) {
|
if (!(result && result.row === startRow && result.col === startCol)) {
|
||||||
result = this._findInLine(term, startRow, startCol, searchOptions, true);
|
result = this._findInLine(term, searchPosition, searchOptions, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search from startRow - 1 to top
|
// Search from startRow - 1 to top
|
||||||
if (!result) {
|
if (!result) {
|
||||||
startCol = this._terminal.cols;
|
searchPosition.startCol = Math.max(searchPosition.startCol, this._terminal.cols);
|
||||||
for (let y = startRow - 1; y >= 0; y--) {
|
for (let y = startRow - 1; y >= 0; y--) {
|
||||||
result = this._findInLine(term, y, startCol, searchOptions, isReverseSearch);
|
searchPosition.startRow = y;
|
||||||
|
result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -158,7 +176,8 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
// If we hit the top and didn't search from the very bottom wrap back down
|
// If we hit the top and didn't search from the very bottom wrap back down
|
||||||
if (!result && startRow !== (this._terminal.buffer.baseY + this._terminal.rows)) {
|
if (!result && startRow !== (this._terminal.buffer.baseY + this._terminal.rows)) {
|
||||||
for (let y = (this._terminal.buffer.baseY + this._terminal.rows); y > startRow; y--) {
|
for (let y = (this._terminal.buffer.baseY + this._terminal.rows); y > startRow; y--) {
|
||||||
result = this._findInLine(term, y, startCol, searchOptions, isReverseSearch);
|
searchPosition.startRow = y;
|
||||||
|
result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -220,18 +239,28 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
* started on an earlier line then it is skipped since it will be properly searched when the terminal line that the
|
* started on an earlier line then it is skipped since it will be properly searched when the terminal line that the
|
||||||
* text starts on is searched.
|
* text starts on is searched.
|
||||||
* @param term The search term.
|
* @param term The search term.
|
||||||
* @param row The line to start the search from.
|
* @param position The position to start the search.
|
||||||
* @param col The column to start the search from.
|
|
||||||
* @param searchOptions Search options.
|
* @param searchOptions Search options.
|
||||||
* @return The search result if it was found.
|
* @return The search result if it was found.
|
||||||
*/
|
*/
|
||||||
protected _findInLine(term: string, row: number, col: number, searchOptions: ISearchOptions = {}, isReverseSearch: boolean = false): ISearchResult | undefined {
|
protected _findInLine(term: string, searchPosition: ISearchPosition, searchOptions: ISearchOptions = {}, isReverseSearch: boolean = false): ISearchResult | undefined {
|
||||||
const terminal = this._terminal!;
|
const terminal = this._terminal!;
|
||||||
|
let row = searchPosition.startRow;
|
||||||
|
const col = searchPosition.startCol;
|
||||||
|
|
||||||
// Ignore wrapped lines, only consider on unwrapped line (first row of command string).
|
// Ignore wrapped lines, only consider on unwrapped line (first row of command string).
|
||||||
const firstLine = terminal.buffer.getLine(row);
|
const firstLine = terminal.buffer.getLine(row);
|
||||||
if (firstLine && firstLine.isWrapped) {
|
if (firstLine && firstLine.isWrapped) {
|
||||||
return;
|
if (isReverseSearch) {
|
||||||
|
searchPosition.startCol += terminal.cols;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will iterate until we find the line start.
|
||||||
|
// When we find it, we will search using the calculated start column.
|
||||||
|
searchPosition.startRow--;
|
||||||
|
searchPosition.startCol += terminal.cols;
|
||||||
|
return this._findInLine(term, searchPosition, searchOptions);
|
||||||
}
|
}
|
||||||
let stringLine = this._linesCache ? this._linesCache[row] : void 0;
|
let stringLine = this._linesCache ? this._linesCache[row] : void 0;
|
||||||
if (stringLine === void 0) {
|
if (stringLine === void 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user