@codingame/monaco-vscode-notebook-service-override 5.2.0 → 6.0.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/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +26 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +549 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +133 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +58 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +6 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +29 -27
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +10 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +27 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +32 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +5 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +42 -40
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +77 -57
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +184 -99
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +56 -112
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +10 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +6 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +3 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +10 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +7 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +6 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +21 -15
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +8 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +6 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +88 -86
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +94 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +73 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +3 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +7 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +5 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +6 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +44 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +34 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +5 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +67 -53
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +11 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +11 -10
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +3 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +5 -3
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +15 -12
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +4 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -156
|
@@ -6,12 +6,13 @@ import { ResourceTextEdit, IBulkEditService } from 'vscode/vscode/vs/editor/brow
|
|
|
6
6
|
import { trimTrailingWhitespace } from 'vscode/vscode/vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
|
7
7
|
import { Position } from 'vscode/vscode/vs/editor/common/core/position';
|
|
8
8
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
9
|
+
import { CodeActionTriggerType } from 'vscode/vscode/vs/editor/common/languages';
|
|
9
10
|
import { IEditorWorkerService } from 'vscode/vscode/vs/editor/common/services/editorWorker';
|
|
10
11
|
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
11
12
|
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
12
13
|
import { applyCodeAction, ApplyCodeActionReason, getCodeActions } from 'vscode/vscode/vs/editor/contrib/codeAction/browser/codeAction';
|
|
13
14
|
import { CodeActionKind, CodeActionTriggerSource } from 'vscode/vscode/vs/editor/contrib/codeAction/common/types';
|
|
14
|
-
import {
|
|
15
|
+
import { getDocumentFormattingEditsWithSelectedProvider, FormattingMode } from 'vscode/vscode/vs/editor/contrib/format/browser/format';
|
|
15
16
|
import { SnippetController2 } from 'vscode/vscode/vs/editor/contrib/snippet/browser/snippetController2';
|
|
16
17
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
17
18
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
@@ -20,17 +21,20 @@ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
|
20
21
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
21
22
|
import { IWorkspaceTrustManagementService } from 'vscode/vscode/vs/platform/workspace/common/workspaceTrust.service';
|
|
22
23
|
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
24
|
+
import { SaveReason } from 'vscode/vscode/vs/workbench/common/editor';
|
|
23
25
|
import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
24
26
|
import { NotebookSetting, CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
25
27
|
import { NotebookFileWorkingCopyModel } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModel';
|
|
26
28
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
29
|
+
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
27
30
|
import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service';
|
|
28
31
|
|
|
29
32
|
const _moduleId = "vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants";
|
|
30
33
|
let FormatOnSaveParticipant = class FormatOnSaveParticipant {
|
|
31
|
-
constructor(editorWorkerService, languageFeaturesService, textModelService, bulkEditService, configurationService) {
|
|
34
|
+
constructor(editorWorkerService, languageFeaturesService, instantiationService, textModelService, bulkEditService, configurationService) {
|
|
32
35
|
this.editorWorkerService = editorWorkerService;
|
|
33
36
|
this.languageFeaturesService = languageFeaturesService;
|
|
37
|
+
this.instantiationService = instantiationService;
|
|
34
38
|
this.textModelService = textModelService;
|
|
35
39
|
this.bulkEditService = bulkEditService;
|
|
36
40
|
this.configurationService = configurationService;
|
|
@@ -39,32 +43,35 @@ let FormatOnSaveParticipant = class FormatOnSaveParticipant {
|
|
|
39
43
|
if (!workingCopy.model || !(workingCopy.model instanceof NotebookFileWorkingCopyModel)) {
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
|
-
if (context.reason ===
|
|
46
|
+
if (context.reason === SaveReason.AUTO) {
|
|
43
47
|
return undefined;
|
|
44
48
|
}
|
|
45
49
|
const enabled = this.configurationService.getValue(NotebookSetting.formatOnSave);
|
|
46
50
|
if (!enabled) {
|
|
47
51
|
return undefined;
|
|
48
52
|
}
|
|
49
|
-
const notebook = workingCopy.model.notebookModel;
|
|
50
53
|
progress.report({ message: ( localizeWithPath(_moduleId, 0, "Formatting")) });
|
|
54
|
+
const notebook = workingCopy.model.notebookModel;
|
|
55
|
+
const formatApplied = await this.instantiationService.invokeFunction(CodeActionParticipantUtils.checkAndRunFormatCodeAction, notebook, progress, token);
|
|
51
56
|
const disposable = ( (new DisposableStore()));
|
|
52
57
|
try {
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
if (!formatApplied) {
|
|
59
|
+
const allCellEdits = await Promise.all(( (notebook.cells.map(async (cell) => {
|
|
60
|
+
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
61
|
+
disposable.add(ref);
|
|
62
|
+
const model = ref.object.textEditorModel;
|
|
63
|
+
const formatEdits = await getDocumentFormattingEditsWithSelectedProvider(this.editorWorkerService, this.languageFeaturesService, model, FormattingMode.Silent, token);
|
|
64
|
+
const edits = [];
|
|
65
|
+
if (formatEdits) {
|
|
66
|
+
edits.push(...( (formatEdits.map(
|
|
67
|
+
edit => ( (new ResourceTextEdit(model.uri, edit, model.getVersionId())))
|
|
68
|
+
))));
|
|
69
|
+
return edits;
|
|
70
|
+
}
|
|
71
|
+
return [];
|
|
72
|
+
}))));
|
|
73
|
+
await this.bulkEditService.apply( allCellEdits.flat(), { label: ( localizeWithPath(_moduleId, 1, "Format Notebook")), code: 'undoredo.formatNotebook', });
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
finally {
|
|
70
77
|
progress.report({ increment: 100 });
|
|
@@ -75,9 +82,10 @@ let FormatOnSaveParticipant = class FormatOnSaveParticipant {
|
|
|
75
82
|
FormatOnSaveParticipant = ( (__decorate([
|
|
76
83
|
( (__param(0, IEditorWorkerService))),
|
|
77
84
|
( (__param(1, ILanguageFeaturesService))),
|
|
78
|
-
( (__param(2,
|
|
79
|
-
( (__param(3,
|
|
80
|
-
( (__param(4,
|
|
85
|
+
( (__param(2, IInstantiationService))),
|
|
86
|
+
( (__param(3, ITextModelService))),
|
|
87
|
+
( (__param(4, IBulkEditService))),
|
|
88
|
+
( (__param(5, IConfigurationService)))
|
|
81
89
|
], FormatOnSaveParticipant)));
|
|
82
90
|
let TrimWhitespaceParticipant = class TrimWhitespaceParticipant {
|
|
83
91
|
constructor(configurationService, editorService, textModelService, bulkEditService) {
|
|
@@ -90,7 +98,7 @@ let TrimWhitespaceParticipant = class TrimWhitespaceParticipant {
|
|
|
90
98
|
const trimTrailingWhitespaceOption = this.configurationService.getValue('files.trimTrailingWhitespace');
|
|
91
99
|
const trimInRegexAndStrings = this.configurationService.getValue('files.trimTrailingWhitespaceInRegexAndStrings');
|
|
92
100
|
if (trimTrailingWhitespaceOption) {
|
|
93
|
-
await this.doTrimTrailingWhitespace(workingCopy, context.reason ===
|
|
101
|
+
await this.doTrimTrailingWhitespace(workingCopy, context.reason === SaveReason.AUTO, trimInRegexAndStrings, progress);
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
async doTrimTrailingWhitespace(workingCopy, isAutoSaved, trimInRegexesAndStrings, progress) {
|
|
@@ -156,7 +164,7 @@ let TrimFinalNewLinesParticipant = class TrimFinalNewLinesParticipant {
|
|
|
156
164
|
}
|
|
157
165
|
async participate(workingCopy, context, progress, _token) {
|
|
158
166
|
if (this.configurationService.getValue('files.trimFinalNewlines')) {
|
|
159
|
-
await this.doTrimFinalNewLines(workingCopy, context.reason ===
|
|
167
|
+
await this.doTrimFinalNewLines(workingCopy, context.reason === SaveReason.AUTO, progress);
|
|
160
168
|
}
|
|
161
169
|
}
|
|
162
170
|
findLastNonEmptyLine(textBuffer) {
|
|
@@ -233,7 +241,7 @@ let InsertFinalNewLineParticipant = class InsertFinalNewLineParticipant {
|
|
|
233
241
|
}
|
|
234
242
|
async participate(workingCopy, context, progress, _token) {
|
|
235
243
|
if (this.configurationService.getValue(NotebookSetting.insertFinalNewline)) {
|
|
236
|
-
await this.doInsertFinalNewLine(workingCopy, context.reason ===
|
|
244
|
+
await this.doInsertFinalNewLine(workingCopy, context.reason === SaveReason.AUTO, progress);
|
|
237
245
|
}
|
|
238
246
|
}
|
|
239
247
|
async doInsertFinalNewLine(workingCopy, isAutoSaved, progress) {
|
|
@@ -284,16 +292,14 @@ InsertFinalNewLineParticipant = ( (__decorate([
|
|
|
284
292
|
( (__param(2, IEditorService)))
|
|
285
293
|
], InsertFinalNewLineParticipant)));
|
|
286
294
|
let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
287
|
-
constructor(configurationService, logService, workspaceTrustManagementService,
|
|
295
|
+
constructor(configurationService, logService, workspaceTrustManagementService, textModelService, instantiationService) {
|
|
288
296
|
this.configurationService = configurationService;
|
|
289
297
|
this.logService = logService;
|
|
290
298
|
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
291
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
292
299
|
this.textModelService = textModelService;
|
|
293
300
|
this.instantiationService = instantiationService;
|
|
294
301
|
}
|
|
295
302
|
async participate(workingCopy, context, progress, token) {
|
|
296
|
-
const nbDisposable = ( (new DisposableStore()));
|
|
297
303
|
const isTrusted = this.workspaceTrustManagementService.isWorkspaceTrusted();
|
|
298
304
|
if (!isTrusted) {
|
|
299
305
|
return;
|
|
@@ -302,10 +308,10 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
302
308
|
return;
|
|
303
309
|
}
|
|
304
310
|
let saveTrigger = '';
|
|
305
|
-
if (context.reason ===
|
|
311
|
+
if (context.reason === SaveReason.AUTO) {
|
|
306
312
|
return undefined;
|
|
307
313
|
}
|
|
308
|
-
else if (context.reason ===
|
|
314
|
+
else if (context.reason === SaveReason.EXPLICIT) {
|
|
309
315
|
saveTrigger = 'explicit';
|
|
310
316
|
}
|
|
311
317
|
else {
|
|
@@ -313,15 +319,9 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
313
319
|
}
|
|
314
320
|
const notebookModel = workingCopy.model.notebookModel;
|
|
315
321
|
const setting = this.configurationService.getValue(NotebookSetting.codeActionsOnSave);
|
|
316
|
-
if (!setting) {
|
|
317
|
-
return undefined;
|
|
318
|
-
}
|
|
319
322
|
const settingItems = Array.isArray(setting)
|
|
320
323
|
? setting
|
|
321
324
|
: ( (Object.keys(setting))).filter(x => setting[x]);
|
|
322
|
-
if (!settingItems.length) {
|
|
323
|
-
return undefined;
|
|
324
|
-
}
|
|
325
325
|
const allCodeActions = this.createCodeActionsOnSave(settingItems);
|
|
326
326
|
const excludedActions = allCodeActions
|
|
327
327
|
.filter(x => setting[x.value] === 'never' || setting[x.value] === false);
|
|
@@ -329,63 +329,102 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
329
329
|
.filter(x => setting[x.value] === saveTrigger || setting[x.value] === true);
|
|
330
330
|
const editorCodeActionsOnSave = includedActions.filter(x => !CodeActionKind.Notebook.contains(x));
|
|
331
331
|
const notebookCodeActionsOnSave = includedActions.filter(x => CodeActionKind.Notebook.contains(x));
|
|
332
|
-
if (
|
|
333
|
-
|
|
332
|
+
if (notebookCodeActionsOnSave.length) {
|
|
333
|
+
const nbDisposable = ( (new DisposableStore()));
|
|
334
|
+
progress.report({ message: ( localizeWithPath(_moduleId, 5, "Running 'Notebook' code actions")) });
|
|
335
|
+
try {
|
|
336
|
+
const cell = notebookModel.cells[0];
|
|
337
|
+
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
338
|
+
nbDisposable.add(ref);
|
|
339
|
+
const textEditorModel = ref.object.textEditorModel;
|
|
340
|
+
await this.instantiationService.invokeFunction(CodeActionParticipantUtils.applyOnSaveGenericCodeActions, textEditorModel, notebookCodeActionsOnSave, excludedActions, progress, token);
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
this.logService.error('Failed to apply notebook code action on save');
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
progress.report({ increment: 100 });
|
|
347
|
+
nbDisposable.dispose();
|
|
348
|
+
}
|
|
334
349
|
}
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
350
|
+
if (editorCodeActionsOnSave.length) {
|
|
351
|
+
if (!Array.isArray(setting)) {
|
|
352
|
+
editorCodeActionsOnSave.sort((a, b) => {
|
|
353
|
+
if (CodeActionKind.SourceFixAll.contains(a)) {
|
|
354
|
+
if (CodeActionKind.SourceFixAll.contains(b)) {
|
|
355
|
+
return 0;
|
|
356
|
+
}
|
|
357
|
+
return -1;
|
|
358
|
+
}
|
|
338
359
|
if (CodeActionKind.SourceFixAll.contains(b)) {
|
|
339
|
-
return
|
|
360
|
+
return 1;
|
|
340
361
|
}
|
|
341
|
-
return
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
362
|
+
return 0;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const cellDisposable = ( (new DisposableStore()));
|
|
366
|
+
progress.report({ message: ( localizeWithPath(_moduleId, 6, "Running 'Cell' code actions")) });
|
|
367
|
+
try {
|
|
368
|
+
await Promise.all(( (notebookModel.cells.map(async (cell) => {
|
|
369
|
+
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
370
|
+
cellDisposable.add(ref);
|
|
371
|
+
const textEditorModel = ref.object.textEditorModel;
|
|
372
|
+
await this.instantiationService.invokeFunction(CodeActionParticipantUtils.applyOnSaveGenericCodeActions, textEditorModel, editorCodeActionsOnSave, excludedActions, progress, token);
|
|
373
|
+
}))));
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
this.logService.error('Failed to apply code action on save');
|
|
377
|
+
}
|
|
378
|
+
finally {
|
|
379
|
+
progress.report({ increment: 100 });
|
|
380
|
+
cellDisposable.dispose();
|
|
381
|
+
}
|
|
348
382
|
}
|
|
349
|
-
|
|
383
|
+
}
|
|
384
|
+
createCodeActionsOnSave(settingItems) {
|
|
385
|
+
const kinds = ( (settingItems.map(x => ( (new HierarchicalKind(x))))));
|
|
386
|
+
return kinds.filter(kind => {
|
|
387
|
+
return kinds.every(otherKind => otherKind.equals(kind) || !otherKind.contains(kind));
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
CodeActionOnSaveParticipant = ( (__decorate([
|
|
392
|
+
( (__param(0, IConfigurationService))),
|
|
393
|
+
( (__param(1, ILogService))),
|
|
394
|
+
( (__param(2, IWorkspaceTrustManagementService))),
|
|
395
|
+
( (__param(3, ITextModelService))),
|
|
396
|
+
( (__param(4, IInstantiationService)))
|
|
397
|
+
], CodeActionOnSaveParticipant)));
|
|
398
|
+
class CodeActionParticipantUtils {
|
|
399
|
+
static async checkAndRunFormatCodeAction(accessor, notebookModel, progress, token) {
|
|
400
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
401
|
+
const textModelService = accessor.get(ITextModelService);
|
|
402
|
+
const logService = accessor.get(ILogService);
|
|
403
|
+
const configurationService = accessor.get(IConfigurationService);
|
|
404
|
+
const formatDisposable = ( (new DisposableStore()));
|
|
405
|
+
let formatResult = false;
|
|
406
|
+
progress.report({ message: ( localizeWithPath(_moduleId, 7, "Running 'Format' code actions")) });
|
|
350
407
|
try {
|
|
351
408
|
const cell = notebookModel.cells[0];
|
|
352
|
-
const ref = await
|
|
353
|
-
|
|
409
|
+
const ref = await textModelService.createModelReference(cell.uri);
|
|
410
|
+
formatDisposable.add(ref);
|
|
354
411
|
const textEditorModel = ref.object.textEditorModel;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
catch {
|
|
358
|
-
this.logService.error('Failed to apply notebook code action on save');
|
|
359
|
-
}
|
|
360
|
-
finally {
|
|
361
|
-
progress.report({ increment: 100 });
|
|
362
|
-
nbDisposable.dispose();
|
|
363
|
-
}
|
|
364
|
-
const disposable = ( (new DisposableStore()));
|
|
365
|
-
progress.report({ message: ( localizeWithPath(_moduleId, 6, "Running 'Cell' code actions")) });
|
|
366
|
-
try {
|
|
367
|
-
await Promise.all(( (notebookModel.cells.map(async (cell) => {
|
|
368
|
-
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
369
|
-
disposable.add(ref);
|
|
370
|
-
const textEditorModel = ref.object.textEditorModel;
|
|
371
|
-
await this.applyOnSaveActions(textEditorModel, editorCodeActionsOnSave, excludedActions, progress, token);
|
|
372
|
-
}))));
|
|
412
|
+
const defaultFormatterExtId = configurationService.getValue(NotebookSetting.defaultFormatter);
|
|
413
|
+
formatResult = await instantiationService.invokeFunction(CodeActionParticipantUtils.applyOnSaveFormatCodeAction, textEditorModel, ( (new HierarchicalKind('notebook.format'))), [], defaultFormatterExtId, progress, token);
|
|
373
414
|
}
|
|
374
415
|
catch {
|
|
375
|
-
|
|
416
|
+
logService.error('Failed to apply notebook format action on save');
|
|
376
417
|
}
|
|
377
418
|
finally {
|
|
378
419
|
progress.report({ increment: 100 });
|
|
379
|
-
|
|
420
|
+
formatDisposable.dispose();
|
|
380
421
|
}
|
|
422
|
+
return formatResult;
|
|
381
423
|
}
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
async applyOnSaveActions(model, codeActionsOnSave, excludes, progress, token) {
|
|
424
|
+
static async applyOnSaveGenericCodeActions(accessor, model, codeActionsOnSave, excludes, progress, token) {
|
|
425
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
426
|
+
const languageFeaturesService = accessor.get(ILanguageFeaturesService);
|
|
427
|
+
const logService = accessor.get(ILogService);
|
|
389
428
|
const getActionProgress = new (class {
|
|
390
429
|
constructor() {
|
|
391
430
|
this._names = ( (new Set()));
|
|
@@ -394,10 +433,10 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
394
433
|
progress.report({
|
|
395
434
|
message: ( localizeWithPath(
|
|
396
435
|
_moduleId,
|
|
397
|
-
|
|
436
|
+
8,
|
|
398
437
|
"Getting code actions from '{0}' ([configure]({1})).",
|
|
399
438
|
( ([...this._names].map(name => `'${name}'`))).join(', '),
|
|
400
|
-
'command:workbench.action.openSettings?%5B%
|
|
439
|
+
'command:workbench.action.openSettings?%5B%22notebook.codeActionsOnSave%22%5D'
|
|
401
440
|
))
|
|
402
441
|
});
|
|
403
442
|
}
|
|
@@ -409,7 +448,7 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
409
448
|
}
|
|
410
449
|
});
|
|
411
450
|
for (const codeActionKind of codeActionsOnSave) {
|
|
412
|
-
const actionsToRun = await this.getActionsToRun(model, codeActionKind, excludes, getActionProgress, token);
|
|
451
|
+
const actionsToRun = await this.getActionsToRun(model, codeActionKind, excludes, languageFeaturesService, getActionProgress, token);
|
|
413
452
|
if (token.isCancellationRequested) {
|
|
414
453
|
actionsToRun.dispose();
|
|
415
454
|
return;
|
|
@@ -431,11 +470,11 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
431
470
|
}
|
|
432
471
|
}
|
|
433
472
|
if (breakFlag) {
|
|
434
|
-
|
|
473
|
+
logService.warn('Failed to apply code action on save, applied to multiple resources.');
|
|
435
474
|
continue;
|
|
436
475
|
}
|
|
437
|
-
progress.report({ message: ( localizeWithPath(_moduleId,
|
|
438
|
-
await
|
|
476
|
+
progress.report({ message: ( localizeWithPath(_moduleId, 9, "Applying code action '{0}'.", action.action.title)) });
|
|
477
|
+
await instantiationService.invokeFunction(applyCodeAction, action, ApplyCodeActionReason.OnSave, {}, token);
|
|
439
478
|
if (token.isCancellationRequested) {
|
|
440
479
|
return;
|
|
441
480
|
}
|
|
@@ -448,22 +487,68 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
448
487
|
}
|
|
449
488
|
}
|
|
450
489
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
490
|
+
static async applyOnSaveFormatCodeAction(accessor, model, formatCodeActionOnSave, excludes, extensionId, progress, token) {
|
|
491
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
492
|
+
const languageFeaturesService = accessor.get(ILanguageFeaturesService);
|
|
493
|
+
const logService = accessor.get(ILogService);
|
|
494
|
+
const getActionProgress = new (class {
|
|
495
|
+
constructor() {
|
|
496
|
+
this._names = ( (new Set()));
|
|
497
|
+
}
|
|
498
|
+
_report() {
|
|
499
|
+
progress.report({
|
|
500
|
+
message: ( localizeWithPath(
|
|
501
|
+
_moduleId,
|
|
502
|
+
8,
|
|
503
|
+
"Getting code actions from '{0}' ([configure]({1})).",
|
|
504
|
+
( ([...this._names].map(name => `'${name}'`))).join(', '),
|
|
505
|
+
'command:workbench.action.openSettings?%5B%22notebook.defaultFormatter%22%5D'
|
|
506
|
+
))
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
report(provider) {
|
|
510
|
+
if (provider.displayName && !( (this._names.has(provider.displayName)))) {
|
|
511
|
+
this._names.add(provider.displayName);
|
|
512
|
+
this._report();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
const providedActions = await CodeActionParticipantUtils.getActionsToRun(model, formatCodeActionOnSave, excludes, languageFeaturesService, getActionProgress, token);
|
|
517
|
+
if (providedActions.validActions.length > 1 && !extensionId) {
|
|
518
|
+
logService.warn('More than one format code action is provided, the 0th one will be used. A default can be specified via `notebook.defaultFormatter` in your settings.');
|
|
519
|
+
}
|
|
520
|
+
if (token.isCancellationRequested) {
|
|
521
|
+
providedActions.dispose();
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
try {
|
|
525
|
+
const action = extensionId ? providedActions.validActions.find(action => action.provider?.extensionId === extensionId) : providedActions.validActions[0];
|
|
526
|
+
if (!action) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
progress.report({ message: ( localizeWithPath(_moduleId, 9, "Applying code action '{0}'.", action.action.title)) });
|
|
530
|
+
await instantiationService.invokeFunction(applyCodeAction, action, ApplyCodeActionReason.OnSave, {}, token);
|
|
531
|
+
if (token.isCancellationRequested) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch {
|
|
536
|
+
logService.error('Failed to apply notebook format code action on save');
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
finally {
|
|
540
|
+
providedActions.dispose();
|
|
541
|
+
}
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
static getActionsToRun(model, codeActionKind, excludes, languageFeaturesService, progress, token) {
|
|
545
|
+
return getCodeActions(languageFeaturesService.codeActionProvider, model, model.getFullModelRange(), {
|
|
546
|
+
type: CodeActionTriggerType.Invoke,
|
|
454
547
|
triggerAction: CodeActionTriggerSource.OnSave,
|
|
455
548
|
filter: { include: codeActionKind, excludes: excludes, includeSourceActions: true },
|
|
456
549
|
}, progress, token);
|
|
457
550
|
}
|
|
458
|
-
}
|
|
459
|
-
CodeActionOnSaveParticipant = ( (__decorate([
|
|
460
|
-
( (__param(0, IConfigurationService))),
|
|
461
|
-
( (__param(1, ILogService))),
|
|
462
|
-
( (__param(2, IWorkspaceTrustManagementService))),
|
|
463
|
-
( (__param(3, ILanguageFeaturesService))),
|
|
464
|
-
( (__param(4, ITextModelService))),
|
|
465
|
-
( (__param(5, IInstantiationService)))
|
|
466
|
-
], CodeActionOnSaveParticipant)));
|
|
551
|
+
}
|
|
467
552
|
function getActiveCellCodeEditor(editorService) {
|
|
468
553
|
const activePane = editorService.activeEditorPane;
|
|
469
554
|
const notebookEditor = getNotebookEditorFromEditorPane(activePane);
|
|
@@ -490,6 +575,6 @@ SaveParticipantsContribution = ( (__decorate([
|
|
|
490
575
|
( (__param(1, IWorkingCopyFileService)))
|
|
491
576
|
], SaveParticipantsContribution)));
|
|
492
577
|
const workbenchContributionsRegistry = ( (Registry.as(Extensions.Workbench)));
|
|
493
|
-
workbenchContributionsRegistry.registerWorkbenchContribution(SaveParticipantsContribution,
|
|
578
|
+
workbenchContributionsRegistry.registerWorkbenchContribution(SaveParticipantsContribution, LifecyclePhase.Restored);
|
|
494
579
|
|
|
495
|
-
export { SaveParticipantsContribution };
|
|
580
|
+
export { CodeActionParticipantUtils, SaveParticipantsContribution };
|
|
@@ -4,6 +4,7 @@ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommon
|
|
|
4
4
|
import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
5
5
|
import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
6
6
|
import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
7
|
+
import { CellStatusbarAlignment } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
7
8
|
import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
8
9
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
9
10
|
|
|
@@ -76,7 +77,7 @@ class TroubleshootController extends Disposable {
|
|
|
76
77
|
items: [
|
|
77
78
|
{
|
|
78
79
|
text: `index: ${i}`,
|
|
79
|
-
alignment:
|
|
80
|
+
alignment: CellStatusbarAlignment.Left,
|
|
80
81
|
priority: Number.MAX_SAFE_INTEGER
|
|
81
82
|
}
|
|
82
83
|
]
|
package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
3
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
4
4
|
import { CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
5
5
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
6
6
|
import { getNotebookEditorFromEditorPane, CellEditState } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
@@ -53,4 +53,4 @@ let NotebookUndoRedoContribution = class NotebookUndoRedoContribution extends Di
|
|
|
53
53
|
NotebookUndoRedoContribution = ( __decorate([
|
|
54
54
|
( __param(0, IEditorService))
|
|
55
55
|
], NotebookUndoRedoContribution));
|
|
56
|
-
registerWorkbenchContribution2(NotebookUndoRedoContribution.ID, NotebookUndoRedoContribution,
|
|
56
|
+
registerWorkbenchContribution2(NotebookUndoRedoContribution.ID, NotebookUndoRedoContribution, WorkbenchPhase.BlockRestore);
|
package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
|
2
2
|
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
3
3
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility.service';
|
|
5
|
-
import { CellEditState } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
5
|
+
import { CellEditState, RenderOutputType } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
6
6
|
import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
7
7
|
import { outputDisplayLimit } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
|
8
8
|
import { CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
@@ -82,7 +82,7 @@ let NotebookViewportContribution = class NotebookViewportContribution extends Di
|
|
|
82
82
|
if (!renderer) {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
|
-
const result = { type:
|
|
85
|
+
const result = { type: RenderOutputType.Extension, renderer, source: output, mimeType: pickedMimeTypeRenderer.mimeType };
|
|
86
86
|
this._notebookEditor.createOutput(viewCell, result, 0, true);
|
|
87
87
|
}
|
|
88
88
|
}
|