@lvce-editor/editor-worker 19.59.1 → 19.60.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.
@@ -4987,7 +4987,8 @@ const updateDerivedState = async (oldState, newState) => {
4987
4987
  if (oldState.lines !== nextState.lines) {
4988
4988
  finalState = {
4989
4989
  ...finalState,
4990
- lightBulbRowIndex: -1
4990
+ lightBulbRowIndex: -1,
4991
+ problemsHighlightedRow: -1
4991
4992
  };
4992
4993
  } else if (shouldUpdateLightBulb(oldState, nextState)) {
4993
4994
  finalState = {
@@ -5187,6 +5188,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
5187
5188
  outerWidth: width,
5188
5189
  platform,
5189
5190
  primarySelectionIndex: 0,
5191
+ problemsHighlightedRow: -1,
5190
5192
  redoStack: [],
5191
5193
  rowHeight: 0,
5192
5194
  savedSelections: [],
@@ -5267,6 +5269,7 @@ const emptyEditor = {
5267
5269
  minLineY: 0,
5268
5270
  outerHeight: 0,
5269
5271
  outerWidth: 0,
5272
+ problemsHighlightedRow: -1,
5270
5273
  redoStack: [],
5271
5274
  scrollBarHeight: 0,
5272
5275
  selectionAnchorPosition: {
@@ -5460,6 +5463,7 @@ const createEditor = async ({
5460
5463
  fontFamily,
5461
5464
  fontSize,
5462
5465
  fontWeight,
5466
+ formatOnSave,
5463
5467
  gutterDecorations: [],
5464
5468
  gutterWidth: 0,
5465
5469
  handleOffset: 0,
@@ -5665,7 +5669,7 @@ const isEqual$3 = (oldState, newState) => {
5665
5669
  };
5666
5670
 
5667
5671
  const isEqual$2 = (oldState, newState) => {
5668
- return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
5672
+ return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
5669
5673
  };
5670
5674
 
5671
5675
  const isEqual$1 = (oldState, newState) => {
@@ -6439,8 +6443,10 @@ const format = async editor => {
6439
6443
  }
6440
6444
  };
6441
6445
 
6442
- // @ts-ignore
6443
6446
  const getNewEditor = async editor => {
6447
+ if (editor.formatOnSave) {
6448
+ return format(editor);
6449
+ }
6444
6450
  return editor;
6445
6451
  };
6446
6452
 
@@ -6519,7 +6525,7 @@ const save = async editor => {
6519
6525
  if (isUntitledFile(uri)) {
6520
6526
  const pickedFilePath = await saveUntitledFile(uri, content, platform, applicationId);
6521
6527
  if (pickedFilePath) {
6522
- if (editor.modified) {
6528
+ if (newEditor.modified) {
6523
6529
  await notifyTabModifiedStatusChange(uri, false, applicationId);
6524
6530
  }
6525
6531
  return {
@@ -6531,7 +6537,7 @@ const save = async editor => {
6531
6537
  return newEditor;
6532
6538
  }
6533
6539
  await saveNormalFile(uri, content, applicationId);
6534
- if (editor.modified) {
6540
+ if (newEditor.modified) {
6535
6541
  await notifyTabModifiedStatusChange(uri, false, applicationId);
6536
6542
  }
6537
6543
  return {
@@ -8822,14 +8828,15 @@ const handleDoubleClick = async (editor, modifier, x, y) => {
8822
8828
  };
8823
8829
 
8824
8830
  const handleFocus$1 = editor => {
8825
- if (editor.focused && editor.focus === FocusEditorText$1) {
8831
+ if (editor.focused && editor.focus === FocusEditorText$1 && editor.problemsHighlightedRow === -1) {
8826
8832
  return editor;
8827
8833
  }
8828
8834
  return {
8829
8835
  ...editor,
8830
8836
  additionalFocus: 0,
8831
8837
  focus: FocusEditorText$1,
8832
- focused: true
8838
+ focused: true,
8839
+ problemsHighlightedRow: -1
8833
8840
  };
8834
8841
  };
8835
8842
 
@@ -14188,6 +14195,7 @@ const kTabSize = 'editor.tabSize';
14188
14195
  const kInsertSpaces = 'editor.insertSpaces';
14189
14196
  const kLineNumbers = 'editor.lineNumbers';
14190
14197
  const kHighlightActiveLineNumber = 'editor.highlightActiveLineNumber';
14198
+ const kFormatOnSave = 'editor.formatOnSave';
14191
14199
  const kDiagnostics = 'editor.diagnostics';
14192
14200
  const kQuickSuggestions = 'editor.quickSuggestions';
14193
14201
  const kAutoClosingQuotes = 'editor.autoClosingQuotes';
@@ -14246,6 +14254,9 @@ const getHighlightActiveLineNumber = async () => {
14246
14254
  const getCompletionTriggerCharacters = async () => {
14247
14255
  return ['.', '/'];
14248
14256
  };
14257
+ const getFormatOnSave = async () => {
14258
+ return (await get$3(kFormatOnSave)) ?? false;
14259
+ };
14249
14260
  const diagnosticsEnabled = async () => {
14250
14261
  return (await get$3(kDiagnostics)) ?? false;
14251
14262
  };
@@ -14263,7 +14274,7 @@ const getBreadcrumbsEnabled = async () => {
14263
14274
  };
14264
14275
 
14265
14276
  const getEditorPreferences = async () => {
14266
- const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, 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(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), getBreadcrumbsEnabled(), getInsertSpaces(), getDragAndDropEnabled()]);
14277
+ 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()]);
14267
14278
  return {
14268
14279
  breadcrumbsEnabled,
14269
14280
  completionTriggerCharacters,
@@ -14272,6 +14283,7 @@ const getEditorPreferences = async () => {
14272
14283
  fontFamily,
14273
14284
  fontSize,
14274
14285
  fontWeight,
14286
+ formatOnSave,
14275
14287
  highlightActiveLineNumber,
14276
14288
  hoverEnabled,
14277
14289
  insertSpaces,
@@ -14614,6 +14626,7 @@ const loadContent = async (state, savedState) => {
14614
14626
  fontFamily,
14615
14627
  fontSize,
14616
14628
  fontWeight,
14629
+ formatOnSave,
14617
14630
  highlightActiveLineNumber,
14618
14631
  hoverEnabled,
14619
14632
  insertSpaces,
@@ -14648,6 +14661,7 @@ const loadContent = async (state, savedState) => {
14648
14661
  fontFamily,
14649
14662
  fontSize,
14650
14663
  fontWeight,
14664
+ formatOnSave,
14651
14665
  highlightActiveLineNumber,
14652
14666
  hoverEnabled,
14653
14667
  insertSpaces,
@@ -14900,6 +14914,11 @@ ${editorSelector} .MergeConflictAction:focus-visible {
14900
14914
  outline: none;
14901
14915
  text-decoration: underline;
14902
14916
  }
14917
+ ${editorSelector} .EditorProblemsHighlightedRow {
14918
+ background: var(--EditorRangeHighlightBackground, rgba(128, 128, 128, 0.18));
14919
+ outline: 1px solid var(--EditorRangeHighlightBorder, rgba(128, 128, 128, 0.35));
14920
+ outline-offset: -1px;
14921
+ }
14903
14922
  ${editorSelector} .EditorLineDecoration {
14904
14923
  color: var(--EditorInlineBlameForeground, rgba(255, 255, 255, 0.5));
14905
14924
  font-style: italic;
@@ -15230,7 +15249,7 @@ const addMergeConflictActions = (dom, rowIndex) => {
15230
15249
  }, text(label));
15231
15250
  }
15232
15251
  };
15233
- const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = []) => {
15252
+ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1) => {
15234
15253
  const dom = [];
15235
15254
  const actualViewRows = visibleViewLineIndices.length === 0 ? Array.from({
15236
15255
  length: textInfos.length
@@ -15249,6 +15268,9 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
15249
15268
  if (rowIndex === highlightedLine) {
15250
15269
  className = mergeClassNames(className, EditorRowHighlighted);
15251
15270
  }
15271
+ if (rowIndex === problemsHighlightedRow) {
15272
+ className = mergeClassNames(className, 'EditorProblemsHighlightedRow');
15273
+ }
15252
15274
  dom.push({
15253
15275
  childCount: textInfo.length / 2 + rowDecorations.length,
15254
15276
  className,
@@ -15272,8 +15294,8 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
15272
15294
  return dom;
15273
15295
  };
15274
15296
 
15275
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = []) => {
15276
- const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices);
15297
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1) => {
15298
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow);
15277
15299
  return [{
15278
15300
  childCount: visibleViewLineIndices.length || textInfos.length,
15279
15301
  className: 'EditorRows',
@@ -15318,8 +15340,8 @@ const editorLayersNode = {
15318
15340
  className: 'EditorLayers',
15319
15341
  type: Div
15320
15342
  };
15321
- const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = []) => {
15322
- return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
15343
+ const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1) => {
15344
+ return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
15323
15345
  };
15324
15346
 
15325
15347
  const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
@@ -15384,13 +15406,14 @@ const getEditorContentVirtualDom = ({
15384
15406
  focused = true,
15385
15407
  highlightedLine = -1,
15386
15408
  lineNumbers = true,
15409
+ problemsHighlightedRow = -1,
15387
15410
  scrollBarDiagnostics = [],
15388
15411
  selectionInfos = [],
15389
15412
  textInfos,
15390
15413
  visibleLineIndices = [],
15391
15414
  visibleViewLineIndices = []
15392
15415
  }) => {
15393
- return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
15416
+ return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
15394
15417
  };
15395
15418
 
15396
15419
  const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
@@ -15544,6 +15567,7 @@ const getEditorVirtualDom = ({
15544
15567
  minimapLines = [],
15545
15568
  minLineY = 0,
15546
15569
  primarySelectionIndex = 0,
15570
+ problemsHighlightedRow = -1,
15547
15571
  scrollBarDiagnostics = [],
15548
15572
  selectionInfos = [],
15549
15573
  selections = new Uint32Array(),
@@ -15595,6 +15619,7 @@ const getEditorVirtualDom = ({
15595
15619
  focused,
15596
15620
  highlightedLine,
15597
15621
  lineNumbers,
15622
+ problemsHighlightedRow,
15598
15623
  scrollBarDiagnostics,
15599
15624
  selectionInfos,
15600
15625
  textInfos,
@@ -15800,10 +15825,10 @@ const renderLines = {
15800
15825
  visibleLineIndices,
15801
15826
  visibleViewLineIndices
15802
15827
  } = newState;
15803
- const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices);
15828
+ const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow);
15804
15829
  return [/* method */'setText', dom];
15805
15830
  },
15806
- isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
15831
+ isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
15807
15832
  };
15808
15833
  const renderSelections = {
15809
15834
  apply: (oldState, newState) => {
@@ -15994,6 +16019,21 @@ const renderEventListeners = () => {
15994
16019
  }];
15995
16020
  };
15996
16021
 
16022
+ const revealProblem = (editor, rowIndex, columnIndex) => {
16023
+ if (!Number.isSafeInteger(rowIndex) || !Number.isSafeInteger(columnIndex)) {
16024
+ return editor;
16025
+ }
16026
+ const row = Math.max(0, Math.min(rowIndex, editor.lines.length - 1));
16027
+ const column = Math.max(0, Math.min(columnIndex, editor.lines[row]?.length ?? 0));
16028
+ const foldingRanges = editor.foldingRanges.filter(range => row <= range.start || row > range.end);
16029
+ const unfolded = foldingRanges.length === editor.foldingRanges.length ? editor : updateLayout(editor, foldingRanges);
16030
+ return {
16031
+ ...cursorSet(unfolded, row, column),
16032
+ focused: false,
16033
+ problemsHighlightedRow: row
16034
+ };
16035
+ };
16036
+
15997
16037
  const saveState = (state, savedState) => {
15998
16038
  const {
15999
16039
  lines,
@@ -16384,6 +16424,19 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
16384
16424
  return finalEditor;
16385
16425
  });
16386
16426
  };
16427
+ const wrapFocusCommand = fn => {
16428
+ const command = wrapCommand((editor, widgetRevision) => {
16429
+ if (editor.widgetRevision !== widgetRevision && editor.focus !== FocusEditorText$1) {
16430
+ return editor;
16431
+ }
16432
+ return fn(editor);
16433
+ });
16434
+ return uid => {
16435
+ // DOM focus events can arrive while a queued command is still opening a widget.
16436
+ const widgetRevision = get$8(uid)?.newState.widgetRevision;
16437
+ return command(uid, widgetRevision);
16438
+ };
16439
+ };
16387
16440
 
16388
16441
  const executeViewletCommand = (uid, commandId, ...args) => {
16389
16442
  return executeViewletCommand$1(commandMap, uid, commandId, ...args);
@@ -16492,7 +16545,7 @@ const commandMap = {
16492
16545
  'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
16493
16546
  'Editor.handleContextMenu': wrapCommand(handleContextMenu),
16494
16547
  'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
16495
- 'Editor.handleFocus': wrapCommand(handleFocus$1),
16548
+ 'Editor.handleFocus': wrapFocusCommand(handleFocus$1),
16496
16549
  'Editor.handleKeyUp': wrapCommand(handleKeyUp, true),
16497
16550
  'Editor.handleMergeConflictActionsMouseDown': wrapCommand(handleMergeConflictActionsMouseDown),
16498
16551
  'Editor.handleMouseDown': wrapCommand(handleMouseDown),
@@ -16554,6 +16607,7 @@ const commandMap = {
16554
16607
  'Editor.replaceRange': wrapCommand(replaceRange),
16555
16608
  'Editor.rerender': wrapCommand(rerender),
16556
16609
  'Editor.resize': wrapCommand(resize),
16610
+ 'Editor.revealProblem': wrapCommand(revealProblem),
16557
16611
  'Editor.save': wrapCommand(save),
16558
16612
  'Editor.saveState': wrapGetter(saveState),
16559
16613
  'Editor.scrollByLines': wrapCommand(scrollByLines),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.59.1",
3
+ "version": "19.60.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"