@lvce-editor/editor-worker 19.71.4 → 19.71.6
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 +32 -7
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -7709,7 +7709,10 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
7709
7709
|
return returnState ? newEditor : undefined;
|
|
7710
7710
|
}
|
|
7711
7711
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
7712
|
-
|
|
7712
|
+
// Another command can commit before the renderer consumes this edit.
|
|
7713
|
+
// Keep its last rendered baseline, including renders completed while we awaited derived state.
|
|
7714
|
+
const renderedState = get$8(uid)?.oldState ?? oldInstance.oldState;
|
|
7715
|
+
set$a(uid, renderedState, newEditorWithDerivedState);
|
|
7713
7716
|
await dispose$3();
|
|
7714
7717
|
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
7715
7718
|
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
@@ -12868,6 +12871,16 @@ const selectionShrink = editor => {
|
|
|
12868
12871
|
|
|
12869
12872
|
// TODO handle virtual space
|
|
12870
12873
|
|
|
12874
|
+
const getOccurrenceIndex = (line, word, startIndex, caseInsensitive) => {
|
|
12875
|
+
if (!caseInsensitive) {
|
|
12876
|
+
return line.indexOf(word, startIndex);
|
|
12877
|
+
}
|
|
12878
|
+
const escapedWord = word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
12879
|
+
const expression = new RegExp(escapedWord, 'giu');
|
|
12880
|
+
expression.lastIndex = startIndex;
|
|
12881
|
+
return expression.exec(line)?.index ?? -1;
|
|
12882
|
+
};
|
|
12883
|
+
|
|
12871
12884
|
// TODO editors behave differently when selecting next occurrence, for example:
|
|
12872
12885
|
|
|
12873
12886
|
// aaa
|
|
@@ -12886,12 +12899,17 @@ const selectionShrink = editor => {
|
|
|
12886
12899
|
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
12887
12900
|
// - sublime selects next position 1, then next position 3
|
|
12888
12901
|
|
|
12889
|
-
const getSelectionEditsSingleLineWord =
|
|
12902
|
+
const getSelectionEditsSingleLineWord = editor => {
|
|
12903
|
+
const {
|
|
12904
|
+
lines,
|
|
12905
|
+
selections
|
|
12906
|
+
} = editor;
|
|
12890
12907
|
const lastSelectionIndex = selections.length - 4;
|
|
12891
12908
|
const [rowIndex, lastSelectionStartColumnIndex,, lastSelectionEndColumnIndex] = getSelectionPairs(selections, lastSelectionIndex);
|
|
12892
12909
|
const line = lines[rowIndex];
|
|
12893
12910
|
const word = line.slice(lastSelectionStartColumnIndex, lastSelectionEndColumnIndex);
|
|
12894
|
-
const
|
|
12911
|
+
const caseInsensitive = editor.selectedTextOccurrenceMatching === 'caseInsensitive';
|
|
12912
|
+
const columnIndexAfter = getOccurrenceIndex(line, word, lastSelectionEndColumnIndex, caseInsensitive);
|
|
12895
12913
|
if (columnIndexAfter !== -1) {
|
|
12896
12914
|
const columnIndexAfterEnd = columnIndexAfter + word.length;
|
|
12897
12915
|
const newSelections = new Uint32Array(selections.length + 4);
|
|
@@ -12908,7 +12926,7 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
12908
12926
|
}
|
|
12909
12927
|
for (let i = rowIndex + 1; i < lines.length; i++) {
|
|
12910
12928
|
const line = lines[i];
|
|
12911
|
-
const columnIndex = line
|
|
12929
|
+
const columnIndex = getOccurrenceIndex(line, word, 0, caseInsensitive);
|
|
12912
12930
|
if (columnIndex !== -1) {
|
|
12913
12931
|
const columnIndexEnd = columnIndex + word.length;
|
|
12914
12932
|
const newSelections = new Uint32Array(selections.length + 4);
|
|
@@ -12929,7 +12947,7 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
12929
12947
|
for (let i = 0; i <= rowIndex; i++) {
|
|
12930
12948
|
const line = lines[i];
|
|
12931
12949
|
let columnIndex = -word.length;
|
|
12932
|
-
while ((columnIndex = line
|
|
12950
|
+
while ((columnIndex = getOccurrenceIndex(line, word, columnIndex + word.length, caseInsensitive)) !== -1) {
|
|
12933
12951
|
let startRowIndex = selections[selectionIndex];
|
|
12934
12952
|
while (startRowIndex < i && selectionIndex < selections.length) {
|
|
12935
12953
|
selectionIndex += 4;
|
|
@@ -12998,7 +13016,7 @@ const getSelectNextOccurrenceResult = editor => {
|
|
|
12998
13016
|
};
|
|
12999
13017
|
}
|
|
13000
13018
|
if (isEverySelectionSingleLine(editor.selections)) {
|
|
13001
|
-
return getSelectionEditsSingleLineWord(editor
|
|
13019
|
+
return getSelectionEditsSingleLineWord(editor);
|
|
13002
13020
|
}
|
|
13003
13021
|
return undefined;
|
|
13004
13022
|
};
|
|
@@ -16012,6 +16030,10 @@ const getMergeConflictActionsEnabled = async () => {
|
|
|
16012
16030
|
const DEFAULT_HOVER_DELAY = 200;
|
|
16013
16031
|
const DEFAULT_MESSAGE_DELAY = 3000;
|
|
16014
16032
|
const MAX_MESSAGE_DELAY = 10_000;
|
|
16033
|
+
const DEFAULT_SELECTED_TEXT_OCCURRENCE_MATCHING = 'caseSensitive';
|
|
16034
|
+
const getSelectedTextOccurrenceMatching = value => {
|
|
16035
|
+
return value === 'caseInsensitive' ? value : DEFAULT_SELECTED_TEXT_OCCURRENCE_MATCHING;
|
|
16036
|
+
};
|
|
16015
16037
|
const getHoverDelay = value => {
|
|
16016
16038
|
const delay = typeof value === 'number' ? value : Number(value);
|
|
16017
16039
|
if (!Number.isFinite(delay) || delay < 0) {
|
|
@@ -16027,7 +16049,7 @@ const getMessageDelay = value => {
|
|
|
16027
16049
|
return delay;
|
|
16028
16050
|
};
|
|
16029
16051
|
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')]);
|
|
16052
|
+
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
16053
|
return {
|
|
16032
16054
|
breadcrumbsEnabled: breadcrumbsEnabled ?? false,
|
|
16033
16055
|
combineWhitespaceTokens: combineWhitespaceTokens ?? true,
|
|
@@ -16053,6 +16075,7 @@ const getEditorPreferences = async () => {
|
|
|
16053
16075
|
minimapEnabled,
|
|
16054
16076
|
roundedSelection: roundedSelection === true,
|
|
16055
16077
|
rowHeight,
|
|
16078
|
+
selectedTextOccurrenceMatching: getSelectedTextOccurrenceMatching(selectedTextOccurrenceMatching),
|
|
16056
16079
|
tabSize
|
|
16057
16080
|
};
|
|
16058
16081
|
};
|
|
@@ -16459,6 +16482,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
16459
16482
|
minimapEnabled,
|
|
16460
16483
|
roundedSelection,
|
|
16461
16484
|
rowHeight,
|
|
16485
|
+
selectedTextOccurrenceMatching,
|
|
16462
16486
|
tabSize
|
|
16463
16487
|
} = await getEditorPreferences();
|
|
16464
16488
|
// TODO support overwriting language id by setting it explicitly or via settings
|
|
@@ -16498,6 +16522,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
16498
16522
|
minimapEnabled,
|
|
16499
16523
|
roundedSelection,
|
|
16500
16524
|
rowHeight,
|
|
16525
|
+
selectedTextOccurrenceMatching,
|
|
16501
16526
|
tabSize,
|
|
16502
16527
|
tokenizerId: state.tokenizerId
|
|
16503
16528
|
};
|