@lvce-editor/extension-host-worker 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensionHostWorkerMain.js +28 -13
- package/package.json +1 -1
|
@@ -5251,30 +5251,43 @@ const getLineMatchRegex = (line, lineNumber, query, matchCase) => {
|
|
|
5251
5251
|
return [];
|
|
5252
5252
|
};
|
|
5253
5253
|
|
|
5254
|
-
const
|
|
5254
|
+
const doesMatchWord = (line, index, wordBoundaries) => {
|
|
5255
|
+
if (index === 0) {
|
|
5256
|
+
return true;
|
|
5257
|
+
}
|
|
5258
|
+
const char = line.charAt(index - 1);
|
|
5259
|
+
return wordBoundaries.includes(char);
|
|
5260
|
+
};
|
|
5261
|
+
const getLineMatchText = (line, lineNumber, query, queryLower, matchCase, matchWholeWord) => {
|
|
5262
|
+
// TODO support multiple matches per line
|
|
5255
5263
|
const lineToQuery = matchCase ? line : line.toLowerCase();
|
|
5256
5264
|
const actualQuery = matchCase ? query : queryLower;
|
|
5257
5265
|
const index = lineToQuery.indexOf(actualQuery);
|
|
5258
|
-
if (index
|
|
5259
|
-
return [
|
|
5260
|
-
type: Match,
|
|
5261
|
-
text: line,
|
|
5262
|
-
start: index,
|
|
5263
|
-
end: index + query.length,
|
|
5264
|
-
lineNumber
|
|
5265
|
-
}];
|
|
5266
|
+
if (index === -1) {
|
|
5267
|
+
return [];
|
|
5266
5268
|
}
|
|
5267
|
-
|
|
5269
|
+
const wordBoundaries = [' ', '\t', '-'];
|
|
5270
|
+
if (matchWholeWord && !doesMatchWord(line, index, wordBoundaries)) {
|
|
5271
|
+
return [];
|
|
5272
|
+
}
|
|
5273
|
+
return [{
|
|
5274
|
+
type: Match,
|
|
5275
|
+
text: line,
|
|
5276
|
+
start: index,
|
|
5277
|
+
end: index + query.length,
|
|
5278
|
+
lineNumber
|
|
5279
|
+
}];
|
|
5268
5280
|
};
|
|
5269
5281
|
|
|
5270
|
-
const getLineMatch = (line, lineNumber, query, queryLower, useRegularExpression, matchCase) => {
|
|
5282
|
+
const getLineMatch = (line, lineNumber, query, queryLower, useRegularExpression, matchCase, matchWholeWord) => {
|
|
5271
5283
|
if (useRegularExpression) {
|
|
5272
5284
|
return getLineMatchRegex(line, lineNumber, query, matchCase);
|
|
5273
5285
|
}
|
|
5274
|
-
return getLineMatchText(line, lineNumber, query, queryLower, matchCase);
|
|
5286
|
+
return getLineMatchText(line, lineNumber, query, queryLower, matchCase, matchWholeWord);
|
|
5275
5287
|
};
|
|
5276
5288
|
|
|
5277
5289
|
const UseRegularExpression = 1 << 1; // 2
|
|
5290
|
+
const MatchWholeWord = 1 << 3; // 8
|
|
5278
5291
|
const MatchCase = 1 << 4; // 16
|
|
5279
5292
|
// 128
|
|
5280
5293
|
|
|
@@ -5285,9 +5298,10 @@ const splitLines = lines => {
|
|
|
5285
5298
|
const textSearchInText = (file, content, query, flags = 0) => {
|
|
5286
5299
|
const matchCase = flags & MatchCase;
|
|
5287
5300
|
const useRegularExpression = flags & UseRegularExpression;
|
|
5301
|
+
const matchWholeWord = flags & MatchWholeWord;
|
|
5288
5302
|
const lines = splitLines(content);
|
|
5289
5303
|
const queryLower = query.toLowerCase();
|
|
5290
|
-
const results = lines.flatMap((line, i) => getLineMatch(line, i, query, queryLower, useRegularExpression, matchCase));
|
|
5304
|
+
const results = lines.flatMap((line, i) => getLineMatch(line, i, query, queryLower, useRegularExpression, matchCase, matchWholeWord));
|
|
5291
5305
|
if (results.length > 0) {
|
|
5292
5306
|
return [{
|
|
5293
5307
|
type: File$3,
|
|
@@ -5406,6 +5420,7 @@ const matchesUri = (uri, relativeRoot, include, exclude) => {
|
|
|
5406
5420
|
}
|
|
5407
5421
|
return true;
|
|
5408
5422
|
};
|
|
5423
|
+
|
|
5409
5424
|
const textSearch = async (scheme, root, query, options, assetDir) => {
|
|
5410
5425
|
string(scheme);
|
|
5411
5426
|
string(root);
|