update pattern and add to grammar

This commit is contained in:
Connor Peet 2020-11-11 10:11:04 -08:00
parent 900bcb7632
commit 49d1396aeb
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD
5 changed files with 14 additions and 5 deletions

View file

@ -8,7 +8,7 @@ import * as pathUtils from 'path';
const FILE_LINE_REGEX = /^(\S.*):$/;
const RESULT_LINE_REGEX = /^(\s+)(\d+)(:| )(\s+)(.*)$/;
const ELISION_REGEX = /\.{3}\(\u200b([0-9]+) characters skipped\u200b\)\.{3}/g;
const ELISION_REGEX = /⟪ ([0-9]+) characters skipped ⟫/g;
const SEARCH_RESULT_SELECTOR = { language: 'search-result', exclusive: true };
const DIRECTIVES = ['# Query:', '# Flags:', '# Including:', '# Excluding:', '# ContextLines:'];
const FLAGS = ['RegExp', 'CaseSensitive', 'IgnoreExcludeSettings', 'WordMatch'];

View file

@ -83,6 +83,7 @@ const scopes = {
meta: 'meta.resultLine.search',
metaSingleLine: 'meta.resultLine.singleLine.search',
metaMultiLine: 'meta.resultLine.multiLine.search',
elision: 'comment meta.resultLine.elision',
prefix: {
meta: 'constant.numeric.integer meta.resultLinePrefix.search',
metaContext: 'meta.resultLinePrefix.contextLinePrefix.search',
@ -220,6 +221,10 @@ const plainText = [
'4': { name: [scopes.resultBlock.result.prefix.meta, scopes.resultBlock.result.prefix.metaContext].join(' ') },
'5': { name: scopes.resultBlock.result.prefix.lineNumber },
}
},
{
match: '⟪ [0-9]+ characters skipped ⟫',
name: [scopes.resultBlock.meta, scopes.resultBlock.result.elision].join(' '),
}
];

View file

@ -263,6 +263,10 @@
"name": "meta.resultLinePrefix.lineNumber.search"
}
}
},
{
"match": "⟪ [0-9]+ characters skipped ⟫",
"name": "meta.resultBlock.search comment meta.resultLine.elision"
}
],
"repository": {

View file

@ -26,8 +26,8 @@ export const SEARCH_EXCLUDE_CONFIG = 'search.exclude';
// Warning: this pattern is used in the search editor to detect offsets. If you
// change this, also change the search-result built-in extension
const SEARCH_ELIDED_PREFIX = '...(\u200b';
const SEARCH_ELIDED_SUFFIX = ' characters skipped\u200b)...';
const SEARCH_ELIDED_PREFIX = '';
const SEARCH_ELIDED_SUFFIX = ' characters skipped';
const SEARCH_ELIDED_MIN_LEN = (SEARCH_ELIDED_PREFIX.length + SEARCH_ELIDED_SUFFIX.length + 5) * 2;
export const ISearchService = createDecorator<ISearchService>('searchService');

View file

@ -105,8 +105,8 @@ suite('TextSearchResult', () => {
const range2 = new SearchRange(5, 133, 5, 136);
const range3 = new SearchRange(5, 141, 5, 144);
const result = new TextSearchMatch('foo bar 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 foo bar baz bar', [range1, range2, range3], previewOptions);
assert.deepEqual(result.preview.matches, [new SearchRange(0, 4, 0, 7), new SearchRange(0, 48, 0, 51), new SearchRange(0, 56, 0, 59)]);
assert.equal(result.preview.text, 'foo bar 123456...(\u200b117 characters skipped\u200b)...o bar baz bar');
assert.deepEqual(result.preview.matches, [new SearchRange(0, 4, 0, 7), new SearchRange(0, 42, 0, 45), new SearchRange(0, 50, 0, 53)]);
assert.equal(result.preview.text, 'foo bar 123456⟪ 117 characters skipped ⟫o bar baz bar');
});
// test('all lines of multiline match', () => {