@lvce-editor/editor-worker 19.59.0 → 19.59.2

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.
@@ -5460,6 +5460,7 @@ const createEditor = async ({
5460
5460
  fontFamily,
5461
5461
  fontSize,
5462
5462
  fontWeight,
5463
+ formatOnSave,
5463
5464
  gutterDecorations: [],
5464
5465
  gutterWidth: 0,
5465
5466
  handleOffset: 0,
@@ -6439,8 +6440,10 @@ const format = async editor => {
6439
6440
  }
6440
6441
  };
6441
6442
 
6442
- // @ts-ignore
6443
6443
  const getNewEditor = async editor => {
6444
+ if (editor.formatOnSave) {
6445
+ return format(editor);
6446
+ }
6444
6447
  return editor;
6445
6448
  };
6446
6449
 
@@ -6519,7 +6522,7 @@ const save = async editor => {
6519
6522
  if (isUntitledFile(uri)) {
6520
6523
  const pickedFilePath = await saveUntitledFile(uri, content, platform, applicationId);
6521
6524
  if (pickedFilePath) {
6522
- if (editor.modified) {
6525
+ if (newEditor.modified) {
6523
6526
  await notifyTabModifiedStatusChange(uri, false, applicationId);
6524
6527
  }
6525
6528
  return {
@@ -6531,7 +6534,7 @@ const save = async editor => {
6531
6534
  return newEditor;
6532
6535
  }
6533
6536
  await saveNormalFile(uri, content, applicationId);
6534
- if (editor.modified) {
6537
+ if (newEditor.modified) {
6535
6538
  await notifyTabModifiedStatusChange(uri, false, applicationId);
6536
6539
  }
6537
6540
  return {
@@ -10400,9 +10403,10 @@ const newStateGenerator$3 = async (state, parentUid) => {
10400
10403
  newState
10401
10404
  } = get$8(parentUid);
10402
10405
  const {
10406
+ applicationId,
10403
10407
  languageId
10404
10408
  } = newState;
10405
- await invoke$5('Completions.create', uid, x, y, width, height, parentUid, languageId);
10409
+ await invoke$5('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
10406
10410
  await invoke$5('Completions.loadContent', uid);
10407
10411
  const diff = await invoke$5('Completions.diff2', uid);
10408
10412
  const commands = await invoke$5('Completions.render2', uid, diff);
@@ -14187,6 +14191,7 @@ const kTabSize = 'editor.tabSize';
14187
14191
  const kInsertSpaces = 'editor.insertSpaces';
14188
14192
  const kLineNumbers = 'editor.lineNumbers';
14189
14193
  const kHighlightActiveLineNumber = 'editor.highlightActiveLineNumber';
14194
+ const kFormatOnSave = 'editor.formatOnSave';
14190
14195
  const kDiagnostics = 'editor.diagnostics';
14191
14196
  const kQuickSuggestions = 'editor.quickSuggestions';
14192
14197
  const kAutoClosingQuotes = 'editor.autoClosingQuotes';
@@ -14245,6 +14250,9 @@ const getHighlightActiveLineNumber = async () => {
14245
14250
  const getCompletionTriggerCharacters = async () => {
14246
14251
  return ['.', '/'];
14247
14252
  };
14253
+ const getFormatOnSave = async () => {
14254
+ return (await get$3(kFormatOnSave)) ?? false;
14255
+ };
14248
14256
  const diagnosticsEnabled = async () => {
14249
14257
  return (await get$3(kDiagnostics)) ?? false;
14250
14258
  };
@@ -14262,7 +14270,7 @@ const getBreadcrumbsEnabled = async () => {
14262
14270
  };
14263
14271
 
14264
14272
  const getEditorPreferences = async () => {
14265
- 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()]);
14273
+ 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()]);
14266
14274
  return {
14267
14275
  breadcrumbsEnabled,
14268
14276
  completionTriggerCharacters,
@@ -14271,6 +14279,7 @@ const getEditorPreferences = async () => {
14271
14279
  fontFamily,
14272
14280
  fontSize,
14273
14281
  fontWeight,
14282
+ formatOnSave,
14274
14283
  highlightActiveLineNumber,
14275
14284
  hoverEnabled,
14276
14285
  insertSpaces,
@@ -14613,6 +14622,7 @@ const loadContent = async (state, savedState) => {
14613
14622
  fontFamily,
14614
14623
  fontSize,
14615
14624
  fontWeight,
14625
+ formatOnSave,
14616
14626
  highlightActiveLineNumber,
14617
14627
  hoverEnabled,
14618
14628
  insertSpaces,
@@ -14647,6 +14657,7 @@ const loadContent = async (state, savedState) => {
14647
14657
  fontFamily,
14648
14658
  fontSize,
14649
14659
  fontWeight,
14660
+ formatOnSave,
14650
14661
  highlightActiveLineNumber,
14651
14662
  hoverEnabled,
14652
14663
  insertSpaces,
@@ -15251,7 +15262,7 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
15251
15262
  dom.push({
15252
15263
  childCount: textInfo.length / 2 + rowDecorations.length,
15253
15264
  className,
15254
- translate: px(difference),
15265
+ translate: difference === 0 ? '' : px(difference),
15255
15266
  type: Div
15256
15267
  });
15257
15268
  for (let j = 0; j < textInfo.length; j += 2) {
@@ -16190,7 +16201,7 @@ const diagnosticsEqual = (left, right) => {
16190
16201
  });
16191
16202
  };
16192
16203
  const diagnosticLayoutEqual = (left, right) => left.charWidth === right.charWidth && left.deltaY === right.deltaY && left.fontFamily === right.fontFamily && left.fontSize === right.fontSize && left.fontWeight === right.fontWeight && left.isMonospaceFont === right.isMonospaceFont && left.itemHeight === right.itemHeight && left.letterSpacing === right.letterSpacing && left.lines === right.lines && left.minLineY === right.minLineY && left.rowHeight === right.rowHeight && left.tabSize === right.tabSize && left.viewLineIndices === right.viewLineIndices && left.width === right.width;
16193
- const isApplicable = (latest, editor) => latest && latest.newState.diagnosticsEnabled && latest.newState.diagnostics === editor.diagnostics && latest.newState.lines === editor.lines && latest.newState.uri === editor.uri;
16204
+ const isApplicable = (latest, editor) => latest && latest.newState.diagnosticsEnabled && latest.newState.diagnostics === editor.diagnostics && latest.newState.languageId === editor.languageId && latest.newState.lines === editor.lines && latest.newState.uri === editor.uri;
16194
16205
  const mergeDiagnostics = (editor, editorWithDiagnostics) => ({
16195
16206
  ...editor,
16196
16207
  decorations: editorWithDiagnostics.decorations,
@@ -16254,7 +16265,7 @@ const editorDiagnosticEffect = {
16254
16265
  apply(editor) {
16255
16266
  return updateDiagnostics(editor);
16256
16267
  },
16257
- isActive: (oldEditor, newEditor) => !oldEditor.initial && newEditor.diagnosticsEnabled && oldEditor.lines !== newEditor.lines
16268
+ isActive: (oldEditor, newEditor) => !oldEditor.initial && newEditor.diagnosticsEnabled && (oldEditor.lines !== newEditor.lines || oldEditor.languageId !== newEditor.languageId)
16258
16269
  };
16259
16270
 
16260
16271
  const cursorUndoLimit = 100;
@@ -16370,6 +16381,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
16370
16381
  visualDecorations: finalEditor.visualDecorations
16371
16382
  });
16372
16383
  set$8(otherUid, instance.oldState, synchronizedEditor);
16384
+ if (editorDiagnosticEffect.isActive(editor, synchronizedEditor)) {
16385
+ void editorDiagnosticEffect.apply(synchronizedEditor);
16386
+ }
16373
16387
  }
16374
16388
  }
16375
16389
  if (lines !== finalEditor.lines && !isUntitledFile(finalEditor.uri)) {
@@ -16380,6 +16394,19 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
16380
16394
  return finalEditor;
16381
16395
  });
16382
16396
  };
16397
+ const wrapFocusCommand = fn => {
16398
+ const command = wrapCommand((editor, widgetRevision) => {
16399
+ if (editor.widgetRevision !== widgetRevision && editor.focus !== FocusEditorText$1) {
16400
+ return editor;
16401
+ }
16402
+ return fn(editor);
16403
+ });
16404
+ return uid => {
16405
+ // DOM focus events can arrive while a queued command is still opening a widget.
16406
+ const widgetRevision = get$8(uid)?.newState.widgetRevision;
16407
+ return command(uid, widgetRevision);
16408
+ };
16409
+ };
16383
16410
 
16384
16411
  const executeViewletCommand = (uid, commandId, ...args) => {
16385
16412
  return executeViewletCommand$1(commandMap, uid, commandId, ...args);
@@ -16488,7 +16515,7 @@ const commandMap = {
16488
16515
  'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
16489
16516
  'Editor.handleContextMenu': wrapCommand(handleContextMenu),
16490
16517
  'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
16491
- 'Editor.handleFocus': wrapCommand(handleFocus$1),
16518
+ 'Editor.handleFocus': wrapFocusCommand(handleFocus$1),
16492
16519
  'Editor.handleKeyUp': wrapCommand(handleKeyUp, true),
16493
16520
  'Editor.handleMergeConflictActionsMouseDown': wrapCommand(handleMergeConflictActionsMouseDown),
16494
16521
  'Editor.handleMouseDown': wrapCommand(handleMouseDown),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.59.0",
3
+ "version": "19.59.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"