@lvce-editor/editor-worker 19.71.4 → 19.71.5
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/editorWorkerMain.js +28 -6
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -12868,6 +12868,16 @@ const selectionShrink = editor => {
|
|
|
12868
12868
|
|
|
12869
12869
|
// TODO handle virtual space
|
|
12870
12870
|
|
|
12871
|
+
const getOccurrenceIndex = (line, word, startIndex, caseInsensitive) => {
|
|
12872
|
+
if (!caseInsensitive) {
|
|
12873
|
+
return line.indexOf(word, startIndex);
|
|
12874
|
+
}
|
|
12875
|
+
const escapedWord = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
12876
|
+
const expression = new RegExp(escapedWord, 'giu');
|
|
12877
|
+
expression.lastIndex = startIndex;
|
|
12878
|
+
return expression.exec(line)?.index ?? -1;
|
|
12879
|
+
};
|
|
12880
|
+
|
|
12871
12881
|
// TODO editors behave differently when selecting next occurrence, for example:
|
|
12872
12882
|
|
|
12873
12883
|
// aaa
|
|
@@ -12886,12 +12896,17 @@ const selectionShrink = editor => {
|
|
|
12886
12896
|
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
12887
12897
|
// - sublime selects next position 1, then next position 3
|
|
12888
12898
|
|
|
12889
|
-
const getSelectionEditsSingleLineWord =
|
|
12899
|
+
const getSelectionEditsSingleLineWord = editor => {
|
|
12900
|
+
const {
|
|
12901
|
+
lines,
|
|
12902
|
+
selections
|
|
12903
|
+
} = editor;
|
|
12890
12904
|
const lastSelectionIndex = selections.length - 4;
|
|
12891
12905
|
const [rowIndex, lastSelectionStartColumnIndex,, lastSelectionEndColumnIndex] = getSelectionPairs(selections, lastSelectionIndex);
|
|
12892
12906
|
const line = lines[rowIndex];
|
|
12893
12907
|
const word = line.slice(lastSelectionStartColumnIndex, lastSelectionEndColumnIndex);
|
|
12894
|
-
const
|
|
12908
|
+
const caseInsensitive = editor.selectedTextOccurrenceMatching === 'caseInsensitive';
|
|
12909
|
+
const columnIndexAfter = getOccurrenceIndex(line, word, lastSelectionEndColumnIndex, caseInsensitive);
|
|
12895
12910
|
if (columnIndexAfter !== -1) {
|
|
12896
12911
|
const columnIndexAfterEnd = columnIndexAfter + word.length;
|
|
12897
12912
|
const newSelections = new Uint32Array(selections.length + 4);
|
|
@@ -12908,7 +12923,7 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
12908
12923
|
}
|
|
12909
12924
|
for (let i = rowIndex + 1; i < lines.length; i++) {
|
|
12910
12925
|
const line = lines[i];
|
|
12911
|
-
const columnIndex = line
|
|
12926
|
+
const columnIndex = getOccurrenceIndex(line, word, 0, caseInsensitive);
|
|
12912
12927
|
if (columnIndex !== -1) {
|
|
12913
12928
|
const columnIndexEnd = columnIndex + word.length;
|
|
12914
12929
|
const newSelections = new Uint32Array(selections.length + 4);
|
|
@@ -12929,7 +12944,7 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
12929
12944
|
for (let i = 0; i <= rowIndex; i++) {
|
|
12930
12945
|
const line = lines[i];
|
|
12931
12946
|
let columnIndex = -word.length;
|
|
12932
|
-
while ((columnIndex = line
|
|
12947
|
+
while ((columnIndex = getOccurrenceIndex(line, word, columnIndex + word.length, caseInsensitive)) !== -1) {
|
|
12933
12948
|
let startRowIndex = selections[selectionIndex];
|
|
12934
12949
|
while (startRowIndex < i && selectionIndex < selections.length) {
|
|
12935
12950
|
selectionIndex += 4;
|
|
@@ -12998,7 +13013,7 @@ const getSelectNextOccurrenceResult = editor => {
|
|
|
12998
13013
|
};
|
|
12999
13014
|
}
|
|
13000
13015
|
if (isEverySelectionSingleLine(editor.selections)) {
|
|
13001
|
-
return getSelectionEditsSingleLineWord(editor
|
|
13016
|
+
return getSelectionEditsSingleLineWord(editor);
|
|
13002
13017
|
}
|
|
13003
13018
|
return undefined;
|
|
13004
13019
|
};
|
|
@@ -16012,6 +16027,10 @@ const getMergeConflictActionsEnabled = async () => {
|
|
|
16012
16027
|
const DEFAULT_HOVER_DELAY = 200;
|
|
16013
16028
|
const DEFAULT_MESSAGE_DELAY = 3000;
|
|
16014
16029
|
const MAX_MESSAGE_DELAY = 10_000;
|
|
16030
|
+
const DEFAULT_SELECTED_TEXT_OCCURRENCE_MATCHING = 'caseSensitive';
|
|
16031
|
+
const getSelectedTextOccurrenceMatching = value => {
|
|
16032
|
+
return value === 'caseInsensitive' ? value : DEFAULT_SELECTED_TEXT_OCCURRENCE_MATCHING;
|
|
16033
|
+
};
|
|
16015
16034
|
const getHoverDelay = value => {
|
|
16016
16035
|
const delay = typeof value === 'number' ? value : Number(value);
|
|
16017
16036
|
if (!Number.isFinite(delay) || delay < 0) {
|
|
@@ -16027,7 +16046,7 @@ const getMessageDelay = value => {
|
|
|
16027
16046
|
return delay;
|
|
16028
16047
|
};
|
|
16029
16048
|
const getEditorPreferences = async () => {
|
|
16030
|
-
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, hoverDelay, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens] = await Promise.all([get$3('editor.diagnostics'), getFontFamily(), getFontSize(), getFontWeight(), get$3('editor.formatOnSave'), get$3('editor.hover'), get$3('editor.hoverDelay'), get$3('editor.messageDelay'), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), get$3('breadcrumbs.enabled'), get$3('editor.insertSpaces'), get$3('editor.dragAndDrop'), get$3('editor.roundedSelection'), get$3('editor.combineWhitespaceTokens')]);
|
|
16049
|
+
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, hoverDelay, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics'), getFontFamily(), getFontSize(), getFontWeight(), get$3('editor.formatOnSave'), get$3('editor.hover'), get$3('editor.hoverDelay'), get$3('editor.messageDelay'), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), get$3('breadcrumbs.enabled'), get$3('editor.insertSpaces'), get$3('editor.dragAndDrop'), get$3('editor.roundedSelection'), get$3('editor.combineWhitespaceTokens'), get$3('editor.selectedTextOccurrenceMatching')]);
|
|
16031
16050
|
return {
|
|
16032
16051
|
breadcrumbsEnabled: breadcrumbsEnabled ?? false,
|
|
16033
16052
|
combineWhitespaceTokens: combineWhitespaceTokens ?? true,
|
|
@@ -16053,6 +16072,7 @@ const getEditorPreferences = async () => {
|
|
|
16053
16072
|
minimapEnabled,
|
|
16054
16073
|
roundedSelection: roundedSelection === true,
|
|
16055
16074
|
rowHeight,
|
|
16075
|
+
selectedTextOccurrenceMatching: getSelectedTextOccurrenceMatching(selectedTextOccurrenceMatching),
|
|
16056
16076
|
tabSize
|
|
16057
16077
|
};
|
|
16058
16078
|
};
|
|
@@ -16459,6 +16479,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
16459
16479
|
minimapEnabled,
|
|
16460
16480
|
roundedSelection,
|
|
16461
16481
|
rowHeight,
|
|
16482
|
+
selectedTextOccurrenceMatching,
|
|
16462
16483
|
tabSize
|
|
16463
16484
|
} = await getEditorPreferences();
|
|
16464
16485
|
// TODO support overwriting language id by setting it explicitly or via settings
|
|
@@ -16498,6 +16519,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
16498
16519
|
minimapEnabled,
|
|
16499
16520
|
roundedSelection,
|
|
16500
16521
|
rowHeight,
|
|
16522
|
+
selectedTextOccurrenceMatching,
|
|
16501
16523
|
tabSize,
|
|
16502
16524
|
tokenizerId: state.tokenizerId
|
|
16503
16525
|
};
|