@lvce-editor/editor-worker 19.60.2 → 19.61.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/editorWorkerMain.js +87 -22
- package/dist/settings.json +8 -0
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -12231,25 +12231,6 @@ const getBlockCommentEdits = (editor, blockComment) => {
|
|
|
12231
12231
|
return changes;
|
|
12232
12232
|
};
|
|
12233
12233
|
|
|
12234
|
-
const toggleBlockComment = async editor => {
|
|
12235
|
-
const offset = getOffsetAtCursor$1(editor);
|
|
12236
|
-
const blockComment = await getBlockComment(editor, offset);
|
|
12237
|
-
if (!blockComment) {
|
|
12238
|
-
return editor;
|
|
12239
|
-
}
|
|
12240
|
-
const edits = getBlockCommentEdits(editor, blockComment);
|
|
12241
|
-
return scheduleDocument(editor, edits);
|
|
12242
|
-
};
|
|
12243
|
-
|
|
12244
|
-
const toggleBreakpoint = editor => {
|
|
12245
|
-
const [rowIndex] = editor.selections;
|
|
12246
|
-
const breakPoints = editor.breakPoints.includes(rowIndex) ? editor.breakPoints.filter(breakPoint => breakPoint !== rowIndex) : [...editor.breakPoints, rowIndex];
|
|
12247
|
-
return {
|
|
12248
|
-
...editor,
|
|
12249
|
-
breakPoints
|
|
12250
|
-
};
|
|
12251
|
-
};
|
|
12252
|
-
|
|
12253
12234
|
const getLineComment = async editor => {
|
|
12254
12235
|
const languageConfiguration = await getLanguageConfiguration(editor);
|
|
12255
12236
|
if (!languageConfiguration?.comments?.lineComment) {
|
|
@@ -12308,6 +12289,72 @@ const getLineCommentEdit = (rowIndex, line, lineComment) => {
|
|
|
12308
12289
|
};
|
|
12309
12290
|
};
|
|
12310
12291
|
|
|
12292
|
+
const getSelectedLineCommentEdits = (editor, lineComment) => {
|
|
12293
|
+
const {
|
|
12294
|
+
lines,
|
|
12295
|
+
selections
|
|
12296
|
+
} = editor;
|
|
12297
|
+
const selectedRows = new Set();
|
|
12298
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
12299
|
+
const startRow = Math.min(selections[i], selections[i + 2]);
|
|
12300
|
+
let endRow = Math.max(selections[i], selections[i + 2]);
|
|
12301
|
+
const endColumn = selections[i + (selections[i] > selections[i + 2] ? 1 : 3)];
|
|
12302
|
+
if (endRow > startRow && endColumn === 0) {
|
|
12303
|
+
endRow--;
|
|
12304
|
+
}
|
|
12305
|
+
for (let row = startRow; row <= endRow; row++) {
|
|
12306
|
+
if (lines[row].trim()) {
|
|
12307
|
+
selectedRows.add(row);
|
|
12308
|
+
}
|
|
12309
|
+
}
|
|
12310
|
+
}
|
|
12311
|
+
const rows = [...selectedRows].toSorted((a, b) => a - b);
|
|
12312
|
+
const remove = rows.every(row => lines[row].trimStart().startsWith(lineComment));
|
|
12313
|
+
return rows.map(rowIndex => {
|
|
12314
|
+
const line = lines[rowIndex];
|
|
12315
|
+
if (remove) {
|
|
12316
|
+
return getLineCommentEdit(rowIndex, line, lineComment);
|
|
12317
|
+
}
|
|
12318
|
+
const columnIndex = line.length - line.trimStart().length;
|
|
12319
|
+
return {
|
|
12320
|
+
deleted: [''],
|
|
12321
|
+
end: {
|
|
12322
|
+
columnIndex,
|
|
12323
|
+
rowIndex
|
|
12324
|
+
},
|
|
12325
|
+
inserted: [`${lineComment} `],
|
|
12326
|
+
origin: ToggleBlockComment$1,
|
|
12327
|
+
start: {
|
|
12328
|
+
columnIndex,
|
|
12329
|
+
rowIndex
|
|
12330
|
+
}
|
|
12331
|
+
};
|
|
12332
|
+
});
|
|
12333
|
+
};
|
|
12334
|
+
|
|
12335
|
+
const toggleBlockComment = async editor => {
|
|
12336
|
+
const offset = getOffsetAtCursor$1(editor);
|
|
12337
|
+
const blockComment = await getBlockComment(editor, offset);
|
|
12338
|
+
if (!blockComment) {
|
|
12339
|
+
const lineComment = await getLineComment(editor);
|
|
12340
|
+
if (!lineComment) {
|
|
12341
|
+
return editor;
|
|
12342
|
+
}
|
|
12343
|
+
return scheduleDocumentAndCursorsSelections(editor, getSelectedLineCommentEdits(editor, lineComment));
|
|
12344
|
+
}
|
|
12345
|
+
const edits = getBlockCommentEdits(editor, blockComment);
|
|
12346
|
+
return scheduleDocument(editor, edits);
|
|
12347
|
+
};
|
|
12348
|
+
|
|
12349
|
+
const toggleBreakpoint = editor => {
|
|
12350
|
+
const [rowIndex] = editor.selections;
|
|
12351
|
+
const breakPoints = editor.breakPoints.includes(rowIndex) ? editor.breakPoints.filter(breakPoint => breakPoint !== rowIndex) : [...editor.breakPoints, rowIndex];
|
|
12352
|
+
return {
|
|
12353
|
+
...editor,
|
|
12354
|
+
breakPoints
|
|
12355
|
+
};
|
|
12356
|
+
};
|
|
12357
|
+
|
|
12311
12358
|
const editorToggleLineComment = async editor => {
|
|
12312
12359
|
const lineComment = await getLineComment(editor);
|
|
12313
12360
|
if (!lineComment) {
|
|
@@ -14282,9 +14329,10 @@ const getBreadcrumbsEnabled = async () => {
|
|
|
14282
14329
|
};
|
|
14283
14330
|
|
|
14284
14331
|
const getEditorPreferences = async () => {
|
|
14285
|
-
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getFormatOnSave(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), getBreadcrumbsEnabled(), getInsertSpaces(), getDragAndDropEnabled()]);
|
|
14332
|
+
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, combineWhitespaceTokens] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getFormatOnSave(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), getBreadcrumbsEnabled(), getInsertSpaces(), getDragAndDropEnabled(), get$3('editor.combineWhitespaceTokens')]);
|
|
14286
14333
|
return {
|
|
14287
14334
|
breadcrumbsEnabled,
|
|
14335
|
+
combineWhitespaceTokens: combineWhitespaceTokens ?? false,
|
|
14288
14336
|
completionTriggerCharacters,
|
|
14289
14337
|
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
14290
14338
|
dragAndDropEnabled,
|
|
@@ -14628,6 +14676,7 @@ const loadContent = async (state, savedState) => {
|
|
|
14628
14676
|
} = state;
|
|
14629
14677
|
const {
|
|
14630
14678
|
breadcrumbsEnabled,
|
|
14679
|
+
combineWhitespaceTokens,
|
|
14631
14680
|
completionTriggerCharacters,
|
|
14632
14681
|
diagnosticsEnabled,
|
|
14633
14682
|
dragAndDropEnabled,
|
|
@@ -14663,6 +14712,7 @@ const loadContent = async (state, savedState) => {
|
|
|
14663
14712
|
...state,
|
|
14664
14713
|
breadcrumbsEnabled,
|
|
14665
14714
|
charWidth,
|
|
14715
|
+
combineWhitespaceTokens,
|
|
14666
14716
|
completionTriggerCharacters,
|
|
14667
14717
|
diagnosticsEnabled,
|
|
14668
14718
|
dragAndDropEnabled,
|
|
@@ -14908,10 +14958,10 @@ ${editorSelector} .GutterRows {
|
|
|
14908
14958
|
}
|
|
14909
14959
|
${editorSelector} .EditorRow,
|
|
14910
14960
|
${editorSelector} .LineNumber {
|
|
14911
|
-
contain: size style;
|
|
14912
14961
|
flex: none;
|
|
14913
14962
|
}
|
|
14914
14963
|
${editorSelector} .EditorRow {
|
|
14964
|
+
contain: size style;
|
|
14915
14965
|
height: var(--EditorRowHeight);
|
|
14916
14966
|
line-height: var(--EditorRowHeight);
|
|
14917
14967
|
}
|
|
@@ -14956,6 +15006,7 @@ ${editorSelector} .EditorLineDecoration {
|
|
|
14956
15006
|
user-select: none;
|
|
14957
15007
|
}
|
|
14958
15008
|
${editorSelector} .LineNumber {
|
|
15009
|
+
contain: content;
|
|
14959
15010
|
position: relative;
|
|
14960
15011
|
}
|
|
14961
15012
|
${editorSelector} .EditorGutterDecoration {
|
|
@@ -15041,6 +15092,19 @@ const Button = 'button';
|
|
|
15041
15092
|
const Code = 'code';
|
|
15042
15093
|
const TextBox = 'textbox';
|
|
15043
15094
|
|
|
15095
|
+
const combineWhitespaceTokens = tokens => {
|
|
15096
|
+
const combined = [];
|
|
15097
|
+
for (let i = 0; i < tokens.length; i += 2) {
|
|
15098
|
+
const tokenText = tokens[i];
|
|
15099
|
+
if (combined.length > 0 && /^[ \t]+$/.test(tokenText)) {
|
|
15100
|
+
combined[combined.length - 2] += tokenText;
|
|
15101
|
+
} else {
|
|
15102
|
+
combined.push(tokenText, tokens[i + 1]);
|
|
15103
|
+
}
|
|
15104
|
+
}
|
|
15105
|
+
return combined;
|
|
15106
|
+
};
|
|
15107
|
+
|
|
15044
15108
|
const getPathname = uri => {
|
|
15045
15109
|
return decodeURIComponent(URL.canParse(uri) ? new URL(uri).pathname : uri);
|
|
15046
15110
|
};
|
|
@@ -15585,6 +15649,7 @@ const getEditorVirtualDom = ({
|
|
|
15585
15649
|
bracketMatchInfos = [],
|
|
15586
15650
|
breadcrumbsEnabled = false,
|
|
15587
15651
|
breakPoints = [],
|
|
15652
|
+
combineWhitespaceTokens: combineWhitespaceTokens$1 = false,
|
|
15588
15653
|
cursorInfos = [],
|
|
15589
15654
|
diagnostics = [],
|
|
15590
15655
|
differences,
|
|
@@ -15659,7 +15724,7 @@ const getEditorVirtualDom = ({
|
|
|
15659
15724
|
problemsHighlightedRow,
|
|
15660
15725
|
scrollBarDiagnostics,
|
|
15661
15726
|
selectionInfos,
|
|
15662
|
-
textInfos,
|
|
15727
|
+
textInfos: combineWhitespaceTokens$1 ? textInfos.map(combineWhitespaceTokens) : textInfos,
|
|
15663
15728
|
visibleLineIndices: visibleLineIndices || [],
|
|
15664
15729
|
visibleViewLineIndices
|
|
15665
15730
|
}), ...minimapDom];
|
package/dist/settings.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"category": "text-editor",
|
|
4
|
+
"description": "Combine space and tab tokens with the preceding token when rendering to reduce DOM nodes",
|
|
5
|
+
"heading": "Combine Whitespace Tokens",
|
|
6
|
+
"id": "editor.combineWhitespaceTokens",
|
|
7
|
+
"type": "boolean",
|
|
8
|
+
"value": false
|
|
9
|
+
},
|
|
2
10
|
{
|
|
3
11
|
"category": "text-editor",
|
|
4
12
|
"description": "The font size of the editor",
|