@lvce-editor/editor-worker 19.59.1 → 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 {
@@ -14188,6 +14191,7 @@ const kTabSize = 'editor.tabSize';
14188
14191
  const kInsertSpaces = 'editor.insertSpaces';
14189
14192
  const kLineNumbers = 'editor.lineNumbers';
14190
14193
  const kHighlightActiveLineNumber = 'editor.highlightActiveLineNumber';
14194
+ const kFormatOnSave = 'editor.formatOnSave';
14191
14195
  const kDiagnostics = 'editor.diagnostics';
14192
14196
  const kQuickSuggestions = 'editor.quickSuggestions';
14193
14197
  const kAutoClosingQuotes = 'editor.autoClosingQuotes';
@@ -14246,6 +14250,9 @@ const getHighlightActiveLineNumber = async () => {
14246
14250
  const getCompletionTriggerCharacters = async () => {
14247
14251
  return ['.', '/'];
14248
14252
  };
14253
+ const getFormatOnSave = async () => {
14254
+ return (await get$3(kFormatOnSave)) ?? false;
14255
+ };
14249
14256
  const diagnosticsEnabled = async () => {
14250
14257
  return (await get$3(kDiagnostics)) ?? false;
14251
14258
  };
@@ -14263,7 +14270,7 @@ const getBreadcrumbsEnabled = async () => {
14263
14270
  };
14264
14271
 
14265
14272
  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()]);
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()]);
14267
14274
  return {
14268
14275
  breadcrumbsEnabled,
14269
14276
  completionTriggerCharacters,
@@ -14272,6 +14279,7 @@ const getEditorPreferences = async () => {
14272
14279
  fontFamily,
14273
14280
  fontSize,
14274
14281
  fontWeight,
14282
+ formatOnSave,
14275
14283
  highlightActiveLineNumber,
14276
14284
  hoverEnabled,
14277
14285
  insertSpaces,
@@ -14614,6 +14622,7 @@ const loadContent = async (state, savedState) => {
14614
14622
  fontFamily,
14615
14623
  fontSize,
14616
14624
  fontWeight,
14625
+ formatOnSave,
14617
14626
  highlightActiveLineNumber,
14618
14627
  hoverEnabled,
14619
14628
  insertSpaces,
@@ -14648,6 +14657,7 @@ const loadContent = async (state, savedState) => {
14648
14657
  fontFamily,
14649
14658
  fontSize,
14650
14659
  fontWeight,
14660
+ formatOnSave,
14651
14661
  highlightActiveLineNumber,
14652
14662
  hoverEnabled,
14653
14663
  insertSpaces,
@@ -16384,6 +16394,19 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
16384
16394
  return finalEditor;
16385
16395
  });
16386
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
+ };
16387
16410
 
16388
16411
  const executeViewletCommand = (uid, commandId, ...args) => {
16389
16412
  return executeViewletCommand$1(commandMap, uid, commandId, ...args);
@@ -16492,7 +16515,7 @@ const commandMap = {
16492
16515
  'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
16493
16516
  'Editor.handleContextMenu': wrapCommand(handleContextMenu),
16494
16517
  'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
16495
- 'Editor.handleFocus': wrapCommand(handleFocus$1),
16518
+ 'Editor.handleFocus': wrapFocusCommand(handleFocus$1),
16496
16519
  'Editor.handleKeyUp': wrapCommand(handleKeyUp, true),
16497
16520
  'Editor.handleMergeConflictActionsMouseDown': wrapCommand(handleMergeConflictActionsMouseDown),
16498
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.1",
3
+ "version": "19.59.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"