@lvce-editor/editor-worker 19.71.3 → 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 +46 -6
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -12402,6 +12402,24 @@ const openRename = async editor => {
|
|
|
12402
12402
|
if (!word) {
|
|
12403
12403
|
return editor;
|
|
12404
12404
|
}
|
|
12405
|
+
const editorState = get$8(editor.uid);
|
|
12406
|
+
if (!editorState) {
|
|
12407
|
+
return editor;
|
|
12408
|
+
}
|
|
12409
|
+
const offsetAtCursor = getOffsetAtCursor$1(editor);
|
|
12410
|
+
const prepareRenameResult = await execute({
|
|
12411
|
+
args: [offsetAtCursor],
|
|
12412
|
+
editor,
|
|
12413
|
+
kind: 'rename',
|
|
12414
|
+
method: 'prepareRename'
|
|
12415
|
+
});
|
|
12416
|
+
if (!prepareRenameResult || typeof prepareRenameResult !== 'object') {
|
|
12417
|
+
return editor;
|
|
12418
|
+
}
|
|
12419
|
+
const latestEditor = get$8(editor.uid)?.newState;
|
|
12420
|
+
if (latestEditor !== editor) {
|
|
12421
|
+
return latestEditor || editor;
|
|
12422
|
+
}
|
|
12405
12423
|
const fullFocus = true;
|
|
12406
12424
|
let editorWithRenameWidget;
|
|
12407
12425
|
try {
|
|
@@ -12850,6 +12868,16 @@ const selectionShrink = editor => {
|
|
|
12850
12868
|
|
|
12851
12869
|
// TODO handle virtual space
|
|
12852
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
|
+
|
|
12853
12881
|
// TODO editors behave differently when selecting next occurrence, for example:
|
|
12854
12882
|
|
|
12855
12883
|
// aaa
|
|
@@ -12868,12 +12896,17 @@ const selectionShrink = editor => {
|
|
|
12868
12896
|
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
12869
12897
|
// - sublime selects next position 1, then next position 3
|
|
12870
12898
|
|
|
12871
|
-
const getSelectionEditsSingleLineWord =
|
|
12899
|
+
const getSelectionEditsSingleLineWord = editor => {
|
|
12900
|
+
const {
|
|
12901
|
+
lines,
|
|
12902
|
+
selections
|
|
12903
|
+
} = editor;
|
|
12872
12904
|
const lastSelectionIndex = selections.length - 4;
|
|
12873
12905
|
const [rowIndex, lastSelectionStartColumnIndex,, lastSelectionEndColumnIndex] = getSelectionPairs(selections, lastSelectionIndex);
|
|
12874
12906
|
const line = lines[rowIndex];
|
|
12875
12907
|
const word = line.slice(lastSelectionStartColumnIndex, lastSelectionEndColumnIndex);
|
|
12876
|
-
const
|
|
12908
|
+
const caseInsensitive = editor.selectedTextOccurrenceMatching === 'caseInsensitive';
|
|
12909
|
+
const columnIndexAfter = getOccurrenceIndex(line, word, lastSelectionEndColumnIndex, caseInsensitive);
|
|
12877
12910
|
if (columnIndexAfter !== -1) {
|
|
12878
12911
|
const columnIndexAfterEnd = columnIndexAfter + word.length;
|
|
12879
12912
|
const newSelections = new Uint32Array(selections.length + 4);
|
|
@@ -12890,7 +12923,7 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
12890
12923
|
}
|
|
12891
12924
|
for (let i = rowIndex + 1; i < lines.length; i++) {
|
|
12892
12925
|
const line = lines[i];
|
|
12893
|
-
const columnIndex = line
|
|
12926
|
+
const columnIndex = getOccurrenceIndex(line, word, 0, caseInsensitive);
|
|
12894
12927
|
if (columnIndex !== -1) {
|
|
12895
12928
|
const columnIndexEnd = columnIndex + word.length;
|
|
12896
12929
|
const newSelections = new Uint32Array(selections.length + 4);
|
|
@@ -12911,7 +12944,7 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
12911
12944
|
for (let i = 0; i <= rowIndex; i++) {
|
|
12912
12945
|
const line = lines[i];
|
|
12913
12946
|
let columnIndex = -word.length;
|
|
12914
|
-
while ((columnIndex = line
|
|
12947
|
+
while ((columnIndex = getOccurrenceIndex(line, word, columnIndex + word.length, caseInsensitive)) !== -1) {
|
|
12915
12948
|
let startRowIndex = selections[selectionIndex];
|
|
12916
12949
|
while (startRowIndex < i && selectionIndex < selections.length) {
|
|
12917
12950
|
selectionIndex += 4;
|
|
@@ -12980,7 +13013,7 @@ const getSelectNextOccurrenceResult = editor => {
|
|
|
12980
13013
|
};
|
|
12981
13014
|
}
|
|
12982
13015
|
if (isEverySelectionSingleLine(editor.selections)) {
|
|
12983
|
-
return getSelectionEditsSingleLineWord(editor
|
|
13016
|
+
return getSelectionEditsSingleLineWord(editor);
|
|
12984
13017
|
}
|
|
12985
13018
|
return undefined;
|
|
12986
13019
|
};
|
|
@@ -15994,6 +16027,10 @@ const getMergeConflictActionsEnabled = async () => {
|
|
|
15994
16027
|
const DEFAULT_HOVER_DELAY = 200;
|
|
15995
16028
|
const DEFAULT_MESSAGE_DELAY = 3000;
|
|
15996
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
|
+
};
|
|
15997
16034
|
const getHoverDelay = value => {
|
|
15998
16035
|
const delay = typeof value === 'number' ? value : Number(value);
|
|
15999
16036
|
if (!Number.isFinite(delay) || delay < 0) {
|
|
@@ -16009,7 +16046,7 @@ const getMessageDelay = value => {
|
|
|
16009
16046
|
return delay;
|
|
16010
16047
|
};
|
|
16011
16048
|
const getEditorPreferences = async () => {
|
|
16012
|
-
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')]);
|
|
16013
16050
|
return {
|
|
16014
16051
|
breadcrumbsEnabled: breadcrumbsEnabled ?? false,
|
|
16015
16052
|
combineWhitespaceTokens: combineWhitespaceTokens ?? true,
|
|
@@ -16035,6 +16072,7 @@ const getEditorPreferences = async () => {
|
|
|
16035
16072
|
minimapEnabled,
|
|
16036
16073
|
roundedSelection: roundedSelection === true,
|
|
16037
16074
|
rowHeight,
|
|
16075
|
+
selectedTextOccurrenceMatching: getSelectedTextOccurrenceMatching(selectedTextOccurrenceMatching),
|
|
16038
16076
|
tabSize
|
|
16039
16077
|
};
|
|
16040
16078
|
};
|
|
@@ -16441,6 +16479,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
16441
16479
|
minimapEnabled,
|
|
16442
16480
|
roundedSelection,
|
|
16443
16481
|
rowHeight,
|
|
16482
|
+
selectedTextOccurrenceMatching,
|
|
16444
16483
|
tabSize
|
|
16445
16484
|
} = await getEditorPreferences();
|
|
16446
16485
|
// TODO support overwriting language id by setting it explicitly or via settings
|
|
@@ -16480,6 +16519,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
16480
16519
|
minimapEnabled,
|
|
16481
16520
|
roundedSelection,
|
|
16482
16521
|
rowHeight,
|
|
16522
|
+
selectedTextOccurrenceMatching,
|
|
16483
16523
|
tabSize,
|
|
16484
16524
|
tokenizerId: state.tokenizerId
|
|
16485
16525
|
};
|