@codingame/monaco-vscode-notebook-service-override 25.1.2 → 26.0.1
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/index.js +2 -2
- package/package.json +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +112 -94
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +95 -96
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +28 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +15 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +22 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +25 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +37 -44
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +211 -115
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +16 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +5 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +57 -49
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +24 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +78 -76
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +14 -15
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +43 -28
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +65 -34
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +19 -16
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +6 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +15 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +28 -16
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +211 -170
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +11 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +158 -156
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +109 -105
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +28 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +26 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +23 -16
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +72 -40
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +233 -186
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +22 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +239 -151
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +85 -86
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +25 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +13 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +8 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +218 -196
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +258 -255
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +106 -98
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +63 -49
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +55 -64
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +21 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +149 -129
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +57 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +286 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.d.ts +22 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.js +82 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +452 -363
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +44 -61
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +9 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +203 -207
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.js +148 -104
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.js +19 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/replEditorAccessibleView.js +9 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +9 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +34 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +29 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +70 -52
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +31 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +78 -41
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +37 -27
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +9 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +8 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +214 -119
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +38 -36
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSource.js +24 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSourceFactory.js +2 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +26 -15
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +35 -15
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +468 -258
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.d.ts +33 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +113 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +74 -58
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +7 -10
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookCellMatching.js +72 -16
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWebWorker.js +70 -51
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js +195 -149
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/replEditorAccessibilityHelp.js +60 -81
- package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +7 -12
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +104 -66
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +115 -77
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +42 -26
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +19 -12
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.d.ts +0 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -198
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +0 -333
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -261
|
@@ -46,7 +46,14 @@ class NotebookSaveParticipant {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
let FormatOnSaveParticipant = class FormatOnSaveParticipant {
|
|
49
|
-
constructor(
|
|
49
|
+
constructor(
|
|
50
|
+
editorWorkerService,
|
|
51
|
+
languageFeaturesService,
|
|
52
|
+
instantiationService,
|
|
53
|
+
textModelService,
|
|
54
|
+
bulkEditService,
|
|
55
|
+
configurationService
|
|
56
|
+
) {
|
|
50
57
|
this.editorWorkerService = editorWorkerService;
|
|
51
58
|
this.languageFeaturesService = languageFeaturesService;
|
|
52
59
|
this.instantiationService = instantiationService;
|
|
@@ -65,17 +72,30 @@ let FormatOnSaveParticipant = class FormatOnSaveParticipant {
|
|
|
65
72
|
if (!enabled) {
|
|
66
73
|
return undefined;
|
|
67
74
|
}
|
|
68
|
-
progress.report({
|
|
75
|
+
progress.report({
|
|
76
|
+
message: ( localize(9655, "Formatting"))
|
|
77
|
+
});
|
|
69
78
|
const notebook = workingCopy.model.notebookModel;
|
|
70
|
-
const formatApplied = await this.instantiationService.invokeFunction(
|
|
79
|
+
const formatApplied = await this.instantiationService.invokeFunction(
|
|
80
|
+
CodeActionParticipantUtils.checkAndRunFormatCodeAction,
|
|
81
|
+
notebook,
|
|
82
|
+
progress,
|
|
83
|
+
token
|
|
84
|
+
);
|
|
71
85
|
const disposable = ( new DisposableStore());
|
|
72
86
|
try {
|
|
73
87
|
if (!formatApplied) {
|
|
74
|
-
const allCellEdits = await Promise.all(( notebook.cells.map(async
|
|
88
|
+
const allCellEdits = await Promise.all(( notebook.cells.map(async cell => {
|
|
75
89
|
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
76
90
|
disposable.add(ref);
|
|
77
91
|
const model = ref.object.textEditorModel;
|
|
78
|
-
const formatEdits = await getDocumentFormattingEditsWithSelectedProvider(
|
|
92
|
+
const formatEdits = await getDocumentFormattingEditsWithSelectedProvider(
|
|
93
|
+
this.editorWorkerService,
|
|
94
|
+
this.languageFeaturesService,
|
|
95
|
+
model,
|
|
96
|
+
FormattingMode.Silent,
|
|
97
|
+
token
|
|
98
|
+
);
|
|
79
99
|
const edits = [];
|
|
80
100
|
if (formatEdits) {
|
|
81
101
|
edits.push(...( formatEdits.map(edit => ( new ResourceTextEdit(model.uri, edit, model.getVersionId())))));
|
|
@@ -83,23 +103,20 @@ let FormatOnSaveParticipant = class FormatOnSaveParticipant {
|
|
|
83
103
|
}
|
|
84
104
|
return [];
|
|
85
105
|
})));
|
|
86
|
-
await this.bulkEditService.apply( allCellEdits.flat(), {
|
|
106
|
+
await this.bulkEditService.apply( allCellEdits.flat(), {
|
|
107
|
+
label: ( localize(9656, "Format Notebook")),
|
|
108
|
+
code: "undoredo.formatNotebook"
|
|
109
|
+
});
|
|
87
110
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
} finally {
|
|
112
|
+
progress.report({
|
|
113
|
+
increment: 100
|
|
114
|
+
});
|
|
91
115
|
disposable.dispose();
|
|
92
116
|
}
|
|
93
117
|
}
|
|
94
118
|
};
|
|
95
|
-
FormatOnSaveParticipant = ( __decorate([
|
|
96
|
-
( __param(0, IEditorWorkerService)),
|
|
97
|
-
( __param(1, ILanguageFeaturesService)),
|
|
98
|
-
( __param(2, IInstantiationService)),
|
|
99
|
-
( __param(3, ITextModelService)),
|
|
100
|
-
( __param(4, IBulkEditService)),
|
|
101
|
-
( __param(5, IConfigurationService))
|
|
102
|
-
], FormatOnSaveParticipant));
|
|
119
|
+
FormatOnSaveParticipant = ( __decorate([( __param(0, IEditorWorkerService)), ( __param(1, ILanguageFeaturesService)), ( __param(2, IInstantiationService)), ( __param(3, ITextModelService)), ( __param(4, IBulkEditService)), ( __param(5, IConfigurationService))], FormatOnSaveParticipant));
|
|
103
120
|
let TrimWhitespaceParticipant = class TrimWhitespaceParticipant extends NotebookSaveParticipant {
|
|
104
121
|
constructor(configurationService, editorService, textModelService, bulkEditService) {
|
|
105
122
|
super(editorService);
|
|
@@ -109,10 +126,15 @@ let TrimWhitespaceParticipant = class TrimWhitespaceParticipant extends Notebook
|
|
|
109
126
|
this.bulkEditService = bulkEditService;
|
|
110
127
|
}
|
|
111
128
|
async participate(workingCopy, context, progress, _token) {
|
|
112
|
-
const trimTrailingWhitespaceOption = this.configurationService.getValue(
|
|
113
|
-
const trimInRegexAndStrings = this.configurationService.getValue(
|
|
129
|
+
const trimTrailingWhitespaceOption = this.configurationService.getValue("files.trimTrailingWhitespace");
|
|
130
|
+
const trimInRegexAndStrings = this.configurationService.getValue("files.trimTrailingWhitespaceInRegexAndStrings");
|
|
114
131
|
if (trimTrailingWhitespaceOption && this.canParticipate()) {
|
|
115
|
-
await this.doTrimTrailingWhitespace(
|
|
132
|
+
await this.doTrimTrailingWhitespace(
|
|
133
|
+
workingCopy,
|
|
134
|
+
context.reason === SaveReason.AUTO,
|
|
135
|
+
trimInRegexAndStrings,
|
|
136
|
+
progress
|
|
137
|
+
);
|
|
116
138
|
}
|
|
117
139
|
}
|
|
118
140
|
async doTrimTrailingWhitespace(workingCopy, isAutoSaved, trimInRegexesAndStrings, progress) {
|
|
@@ -125,7 +147,7 @@ let TrimWhitespaceParticipant = class TrimWhitespaceParticipant extends Notebook
|
|
|
125
147
|
let cursors = [];
|
|
126
148
|
let prevSelection = [];
|
|
127
149
|
try {
|
|
128
|
-
const allCellEdits = await Promise.all(( notebook.cells.map(async
|
|
150
|
+
const allCellEdits = await Promise.all(( notebook.cells.map(async cell => {
|
|
129
151
|
if (cell.cellKind !== CellKind.Code) {
|
|
130
152
|
return [];
|
|
131
153
|
}
|
|
@@ -149,23 +171,25 @@ let TrimWhitespaceParticipant = class TrimWhitespaceParticipant extends Notebook
|
|
|
149
171
|
if (!ops.length) {
|
|
150
172
|
return [];
|
|
151
173
|
}
|
|
152
|
-
return ( ops.map(op => ( new ResourceTextEdit(model.uri, {
|
|
174
|
+
return ( ops.map(op => ( new ResourceTextEdit(model.uri, {
|
|
175
|
+
...op,
|
|
176
|
+
text: op.text || ""
|
|
177
|
+
}, model.getVersionId()))));
|
|
153
178
|
})));
|
|
154
179
|
const filteredEdits = allCellEdits.flat().filter(edit => edit !== undefined);
|
|
155
|
-
await this.bulkEditService.apply(filteredEdits, {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
180
|
+
await this.bulkEditService.apply(filteredEdits, {
|
|
181
|
+
label: ( localize(9657, "Notebook Trim Trailing Whitespace")),
|
|
182
|
+
code: "undoredo.notebookTrimTrailingWhitespace"
|
|
183
|
+
});
|
|
184
|
+
} finally {
|
|
185
|
+
progress.report({
|
|
186
|
+
increment: 100
|
|
187
|
+
});
|
|
159
188
|
disposable.dispose();
|
|
160
189
|
}
|
|
161
190
|
}
|
|
162
191
|
};
|
|
163
|
-
TrimWhitespaceParticipant = ( __decorate([
|
|
164
|
-
( __param(0, IConfigurationService)),
|
|
165
|
-
( __param(1, IEditorService)),
|
|
166
|
-
( __param(2, ITextModelService)),
|
|
167
|
-
( __param(3, IBulkEditService))
|
|
168
|
-
], TrimWhitespaceParticipant));
|
|
192
|
+
TrimWhitespaceParticipant = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IEditorService)), ( __param(2, ITextModelService)), ( __param(3, IBulkEditService))], TrimWhitespaceParticipant));
|
|
169
193
|
let TrimFinalNewLinesParticipant = class TrimFinalNewLinesParticipant extends NotebookSaveParticipant {
|
|
170
194
|
constructor(configurationService, editorService, bulkEditService) {
|
|
171
195
|
super(editorService);
|
|
@@ -174,7 +198,7 @@ let TrimFinalNewLinesParticipant = class TrimFinalNewLinesParticipant extends No
|
|
|
174
198
|
this.bulkEditService = bulkEditService;
|
|
175
199
|
}
|
|
176
200
|
async participate(workingCopy, context, progress, _token) {
|
|
177
|
-
if (this.configurationService.getValue(
|
|
201
|
+
if (this.configurationService.getValue("files.trimFinalNewlines") && this.canParticipate()) {
|
|
178
202
|
await this.doTrimFinalNewLines(workingCopy, context.reason === SaveReason.AUTO, progress);
|
|
179
203
|
}
|
|
180
204
|
}
|
|
@@ -195,7 +219,7 @@ let TrimFinalNewLinesParticipant = class TrimFinalNewLinesParticipant extends No
|
|
|
195
219
|
const notebook = workingCopy.model.notebookModel;
|
|
196
220
|
const activeCellEditor = getActiveCellCodeEditor(this.editorService);
|
|
197
221
|
try {
|
|
198
|
-
const allCellEdits = await Promise.all(( notebook.cells.map(async
|
|
222
|
+
const allCellEdits = await Promise.all(( notebook.cells.map(async cell => {
|
|
199
223
|
if (cell.cellKind !== CellKind.Code) {
|
|
200
224
|
return;
|
|
201
225
|
}
|
|
@@ -222,26 +246,25 @@ let TrimFinalNewLinesParticipant = class TrimFinalNewLinesParticipant extends No
|
|
|
222
246
|
if (deletionRange.isEmpty()) {
|
|
223
247
|
return;
|
|
224
248
|
}
|
|
225
|
-
return ( new ResourceTextEdit(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
));
|
|
249
|
+
return ( new ResourceTextEdit(cell.uri, {
|
|
250
|
+
range: deletionRange,
|
|
251
|
+
text: ""
|
|
252
|
+
}, cell.textModel?.getVersionId()));
|
|
230
253
|
})));
|
|
231
254
|
const filteredEdits = allCellEdits.flat().filter(edit => edit !== undefined);
|
|
232
|
-
await this.bulkEditService.apply(filteredEdits, {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
255
|
+
await this.bulkEditService.apply(filteredEdits, {
|
|
256
|
+
label: ( localize(9658, "Trim Final New Lines")),
|
|
257
|
+
code: "undoredo.trimFinalNewLines"
|
|
258
|
+
});
|
|
259
|
+
} finally {
|
|
260
|
+
progress.report({
|
|
261
|
+
increment: 100
|
|
262
|
+
});
|
|
236
263
|
disposable.dispose();
|
|
237
264
|
}
|
|
238
265
|
}
|
|
239
266
|
};
|
|
240
|
-
TrimFinalNewLinesParticipant = ( __decorate([
|
|
241
|
-
( __param(0, IConfigurationService)),
|
|
242
|
-
( __param(1, IEditorService)),
|
|
243
|
-
( __param(2, IBulkEditService))
|
|
244
|
-
], TrimFinalNewLinesParticipant));
|
|
267
|
+
TrimFinalNewLinesParticipant = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IEditorService)), ( __param(2, IBulkEditService))], TrimFinalNewLinesParticipant));
|
|
245
268
|
let InsertFinalNewLineParticipant = class InsertFinalNewLineParticipant extends NotebookSaveParticipant {
|
|
246
269
|
constructor(configurationService, bulkEditService, editorService) {
|
|
247
270
|
super(editorService);
|
|
@@ -266,7 +289,7 @@ let InsertFinalNewLineParticipant = class InsertFinalNewLineParticipant extends
|
|
|
266
289
|
selections = activeCellEditor.getSelections() ?? [];
|
|
267
290
|
}
|
|
268
291
|
try {
|
|
269
|
-
const allCellEdits = await Promise.all(( notebook.cells.map(async
|
|
292
|
+
const allCellEdits = await Promise.all(( notebook.cells.map(async cell => {
|
|
270
293
|
if (cell.cellKind !== CellKind.Code) {
|
|
271
294
|
return;
|
|
272
295
|
}
|
|
@@ -275,32 +298,41 @@ let InsertFinalNewLineParticipant = class InsertFinalNewLineParticipant extends
|
|
|
275
298
|
if (!lineCount || lastLineIsEmptyOrWhitespace) {
|
|
276
299
|
return;
|
|
277
300
|
}
|
|
278
|
-
return ( new ResourceTextEdit(cell.uri, {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
301
|
+
return ( new ResourceTextEdit(cell.uri, {
|
|
302
|
+
range: ( new Range(
|
|
303
|
+
lineCount + 1,
|
|
304
|
+
cell.textBuffer.getLineLength(lineCount),
|
|
305
|
+
lineCount + 1,
|
|
306
|
+
cell.textBuffer.getLineLength(lineCount)
|
|
307
|
+
)),
|
|
308
|
+
text: cell.textBuffer.getEOL()
|
|
309
|
+
}, cell.textModel?.getVersionId()));
|
|
284
310
|
})));
|
|
285
311
|
const filteredEdits = allCellEdits.filter(edit => edit !== undefined);
|
|
286
|
-
await this.bulkEditService.apply(filteredEdits, {
|
|
312
|
+
await this.bulkEditService.apply(filteredEdits, {
|
|
313
|
+
label: ( localize(9659, "Insert Final New Line")),
|
|
314
|
+
code: "undoredo.insertFinalNewLine"
|
|
315
|
+
});
|
|
287
316
|
if (activeCellEditor && selections) {
|
|
288
317
|
activeCellEditor.setSelections(selections);
|
|
289
318
|
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
319
|
+
} finally {
|
|
320
|
+
progress.report({
|
|
321
|
+
increment: 100
|
|
322
|
+
});
|
|
293
323
|
disposable.dispose();
|
|
294
324
|
}
|
|
295
325
|
}
|
|
296
326
|
};
|
|
297
|
-
InsertFinalNewLineParticipant = ( __decorate([
|
|
298
|
-
( __param(0, IConfigurationService)),
|
|
299
|
-
( __param(1, IBulkEditService)),
|
|
300
|
-
( __param(2, IEditorService))
|
|
301
|
-
], InsertFinalNewLineParticipant));
|
|
327
|
+
InsertFinalNewLineParticipant = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IBulkEditService)), ( __param(2, IEditorService))], InsertFinalNewLineParticipant));
|
|
302
328
|
let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
303
|
-
constructor(
|
|
329
|
+
constructor(
|
|
330
|
+
configurationService,
|
|
331
|
+
logService,
|
|
332
|
+
workspaceTrustManagementService,
|
|
333
|
+
textModelService,
|
|
334
|
+
instantiationService
|
|
335
|
+
) {
|
|
304
336
|
this.configurationService = configurationService;
|
|
305
337
|
this.logService = logService;
|
|
306
338
|
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
@@ -315,43 +347,46 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
315
347
|
if (!workingCopy.model || !(workingCopy.model instanceof NotebookFileWorkingCopyModel)) {
|
|
316
348
|
return;
|
|
317
349
|
}
|
|
318
|
-
let saveTrigger =
|
|
350
|
+
let saveTrigger = "";
|
|
319
351
|
if (context.reason === SaveReason.AUTO) {
|
|
320
352
|
return undefined;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
353
|
+
} else if (context.reason === SaveReason.EXPLICIT) {
|
|
354
|
+
saveTrigger = "explicit";
|
|
355
|
+
} else {
|
|
326
356
|
return undefined;
|
|
327
357
|
}
|
|
328
358
|
const notebookModel = workingCopy.model.notebookModel;
|
|
329
359
|
const setting = this.configurationService.getValue(NotebookSetting.codeActionsOnSave);
|
|
330
|
-
const settingItems = Array.isArray(setting)
|
|
331
|
-
? setting
|
|
332
|
-
: ( Object.keys(setting)).filter(x => setting[x]);
|
|
360
|
+
const settingItems = Array.isArray(setting) ? setting : ( Object.keys(setting)).filter(x => setting[x]);
|
|
333
361
|
const allCodeActions = this.createCodeActionsOnSave(settingItems);
|
|
334
|
-
const excludedActions = allCodeActions
|
|
335
|
-
|
|
336
|
-
const includedActions = allCodeActions
|
|
337
|
-
.filter(x => setting[x.value] === saveTrigger || setting[x.value] === true);
|
|
362
|
+
const excludedActions = allCodeActions.filter(x => setting[x.value] === "never" || setting[x.value] === false);
|
|
363
|
+
const includedActions = allCodeActions.filter(x => setting[x.value] === saveTrigger || setting[x.value] === true);
|
|
338
364
|
const editorCodeActionsOnSave = includedActions.filter(x => !CodeActionKind.Notebook.contains(x));
|
|
339
365
|
const notebookCodeActionsOnSave = includedActions.filter(x => CodeActionKind.Notebook.contains(x));
|
|
340
366
|
if (notebookCodeActionsOnSave.length) {
|
|
341
367
|
const nbDisposable = ( new DisposableStore());
|
|
342
|
-
progress.report({
|
|
368
|
+
progress.report({
|
|
369
|
+
message: ( localize(9660, "Running 'Notebook' code actions"))
|
|
370
|
+
});
|
|
343
371
|
try {
|
|
344
372
|
const cell = notebookModel.cells[0];
|
|
345
373
|
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
346
374
|
nbDisposable.add(ref);
|
|
347
375
|
const textEditorModel = ref.object.textEditorModel;
|
|
348
|
-
await this.instantiationService.invokeFunction(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
376
|
+
await this.instantiationService.invokeFunction(
|
|
377
|
+
CodeActionParticipantUtils.applyOnSaveGenericCodeActions,
|
|
378
|
+
textEditorModel,
|
|
379
|
+
notebookCodeActionsOnSave,
|
|
380
|
+
excludedActions,
|
|
381
|
+
progress,
|
|
382
|
+
token
|
|
383
|
+
);
|
|
384
|
+
} catch {
|
|
385
|
+
this.logService.error("Failed to apply notebook code action on save");
|
|
386
|
+
} finally {
|
|
387
|
+
progress.report({
|
|
388
|
+
increment: 100
|
|
389
|
+
});
|
|
355
390
|
nbDisposable.dispose();
|
|
356
391
|
}
|
|
357
392
|
}
|
|
@@ -371,20 +406,29 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
371
406
|
});
|
|
372
407
|
}
|
|
373
408
|
const cellDisposable = ( new DisposableStore());
|
|
374
|
-
progress.report({
|
|
409
|
+
progress.report({
|
|
410
|
+
message: ( localize(9661, "Running 'Cell' code actions"))
|
|
411
|
+
});
|
|
375
412
|
try {
|
|
376
|
-
await Promise.all(( notebookModel.cells.map(async
|
|
413
|
+
await Promise.all(( notebookModel.cells.map(async cell => {
|
|
377
414
|
const ref = await this.textModelService.createModelReference(cell.uri);
|
|
378
415
|
cellDisposable.add(ref);
|
|
379
416
|
const textEditorModel = ref.object.textEditorModel;
|
|
380
|
-
await this.instantiationService.invokeFunction(
|
|
417
|
+
await this.instantiationService.invokeFunction(
|
|
418
|
+
CodeActionParticipantUtils.applyOnSaveGenericCodeActions,
|
|
419
|
+
textEditorModel,
|
|
420
|
+
editorCodeActionsOnSave,
|
|
421
|
+
excludedActions,
|
|
422
|
+
progress,
|
|
423
|
+
token
|
|
424
|
+
);
|
|
381
425
|
})));
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
426
|
+
} catch {
|
|
427
|
+
this.logService.error("Failed to apply code action on save");
|
|
428
|
+
} finally {
|
|
429
|
+
progress.report({
|
|
430
|
+
increment: 100
|
|
431
|
+
});
|
|
388
432
|
cellDisposable.dispose();
|
|
389
433
|
}
|
|
390
434
|
}
|
|
@@ -396,13 +440,7 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
396
440
|
});
|
|
397
441
|
}
|
|
398
442
|
};
|
|
399
|
-
CodeActionOnSaveParticipant = ( __decorate([
|
|
400
|
-
( __param(0, IConfigurationService)),
|
|
401
|
-
( __param(1, ILogService)),
|
|
402
|
-
( __param(2, IWorkspaceTrustManagementService)),
|
|
403
|
-
( __param(3, ITextModelService)),
|
|
404
|
-
( __param(4, IInstantiationService))
|
|
405
|
-
], CodeActionOnSaveParticipant));
|
|
443
|
+
CodeActionOnSaveParticipant = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, ILogService)), ( __param(2, IWorkspaceTrustManagementService)), ( __param(3, ITextModelService)), ( __param(4, IInstantiationService))], CodeActionOnSaveParticipant));
|
|
406
444
|
class CodeActionParticipantUtils {
|
|
407
445
|
static async checkAndRunFormatCodeAction(accessor, notebookModel, progress, token) {
|
|
408
446
|
const instantiationService = accessor.get(IInstantiationService);
|
|
@@ -411,20 +449,30 @@ class CodeActionParticipantUtils {
|
|
|
411
449
|
const configurationService = accessor.get(IConfigurationService);
|
|
412
450
|
const formatDisposable = ( new DisposableStore());
|
|
413
451
|
let formatResult = false;
|
|
414
|
-
progress.report({
|
|
452
|
+
progress.report({
|
|
453
|
+
message: ( localize(9662, "Running 'Format' code actions"))
|
|
454
|
+
});
|
|
415
455
|
try {
|
|
416
456
|
const cell = notebookModel.cells[0];
|
|
417
457
|
const ref = await textModelService.createModelReference(cell.uri);
|
|
418
458
|
formatDisposable.add(ref);
|
|
419
459
|
const textEditorModel = ref.object.textEditorModel;
|
|
420
460
|
const defaultFormatterExtId = configurationService.getValue(NotebookSetting.defaultFormatter);
|
|
421
|
-
formatResult = await instantiationService.invokeFunction(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
461
|
+
formatResult = await instantiationService.invokeFunction(
|
|
462
|
+
CodeActionParticipantUtils.applyOnSaveFormatCodeAction,
|
|
463
|
+
textEditorModel,
|
|
464
|
+
( new HierarchicalKind("notebook.format")),
|
|
465
|
+
[],
|
|
466
|
+
defaultFormatterExtId,
|
|
467
|
+
progress,
|
|
468
|
+
token
|
|
469
|
+
);
|
|
470
|
+
} catch {
|
|
471
|
+
logService.error("Failed to apply notebook format action on save");
|
|
472
|
+
} finally {
|
|
473
|
+
progress.report({
|
|
474
|
+
increment: 100
|
|
475
|
+
});
|
|
428
476
|
formatDisposable.dispose();
|
|
429
477
|
}
|
|
430
478
|
return formatResult;
|
|
@@ -440,10 +488,10 @@ class CodeActionParticipantUtils {
|
|
|
440
488
|
_report() {
|
|
441
489
|
progress.report({
|
|
442
490
|
message: ( localize(
|
|
443
|
-
|
|
491
|
+
9663,
|
|
444
492
|
"Getting code actions from '{0}' ([configure]({1})).",
|
|
445
|
-
( [...this._names].map(name => `'${name}'`)).join(
|
|
446
|
-
|
|
493
|
+
( [...this._names].map(name => `'${name}'`)).join(", "),
|
|
494
|
+
"command:workbench.action.openSettings?%5B%22notebook.codeActionsOnSave%22%5D"
|
|
447
495
|
))
|
|
448
496
|
});
|
|
449
497
|
}
|
|
@@ -453,9 +501,16 @@ class CodeActionParticipantUtils {
|
|
|
453
501
|
this._report();
|
|
454
502
|
}
|
|
455
503
|
}
|
|
456
|
-
});
|
|
504
|
+
})();
|
|
457
505
|
for (const codeActionKind of codeActionsOnSave) {
|
|
458
|
-
const actionsToRun = await CodeActionParticipantUtils.getActionsToRun(
|
|
506
|
+
const actionsToRun = await CodeActionParticipantUtils.getActionsToRun(
|
|
507
|
+
model,
|
|
508
|
+
codeActionKind,
|
|
509
|
+
excludes,
|
|
510
|
+
languageFeaturesService,
|
|
511
|
+
getActionProgress,
|
|
512
|
+
token
|
|
513
|
+
);
|
|
459
514
|
if (token.isCancellationRequested) {
|
|
460
515
|
actionsToRun.dispose();
|
|
461
516
|
return;
|
|
@@ -464,37 +519,43 @@ class CodeActionParticipantUtils {
|
|
|
464
519
|
for (const action of actionsToRun.validActions) {
|
|
465
520
|
const codeActionEdits = action.action.edit?.edits;
|
|
466
521
|
let breakFlag = false;
|
|
467
|
-
if (!action.action.kind?.startsWith(
|
|
522
|
+
if (!action.action.kind?.startsWith("notebook")) {
|
|
468
523
|
for (const edit of codeActionEdits ?? []) {
|
|
469
524
|
const workspaceTextEdit = edit;
|
|
470
525
|
if (workspaceTextEdit.resource && isEqual(workspaceTextEdit.resource, model.uri)) {
|
|
471
526
|
continue;
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
527
|
+
} else {
|
|
474
528
|
breakFlag = true;
|
|
475
529
|
break;
|
|
476
530
|
}
|
|
477
531
|
}
|
|
478
532
|
}
|
|
479
533
|
if (breakFlag) {
|
|
480
|
-
logService.warn(
|
|
534
|
+
logService.warn("Failed to apply code action on save, applied to multiple resources.");
|
|
481
535
|
continue;
|
|
482
536
|
}
|
|
483
|
-
progress.report({
|
|
537
|
+
progress.report({
|
|
538
|
+
message: ( localize(9664, "Applying code action '{0}'.", action.action.title))
|
|
539
|
+
});
|
|
484
540
|
await instantiationService.invokeFunction(applyCodeAction, action, ApplyCodeActionReason.OnSave, {}, token);
|
|
485
541
|
if (token.isCancellationRequested) {
|
|
486
542
|
return;
|
|
487
543
|
}
|
|
488
544
|
}
|
|
489
|
-
}
|
|
490
|
-
catch {
|
|
491
|
-
}
|
|
492
|
-
finally {
|
|
545
|
+
} catch {} finally {
|
|
493
546
|
actionsToRun.dispose();
|
|
494
547
|
}
|
|
495
548
|
}
|
|
496
549
|
}
|
|
497
|
-
static async applyOnSaveFormatCodeAction(
|
|
550
|
+
static async applyOnSaveFormatCodeAction(
|
|
551
|
+
accessor,
|
|
552
|
+
model,
|
|
553
|
+
formatCodeActionOnSave,
|
|
554
|
+
excludes,
|
|
555
|
+
extensionId,
|
|
556
|
+
progress,
|
|
557
|
+
token
|
|
558
|
+
) {
|
|
498
559
|
const instantiationService = accessor.get(IInstantiationService);
|
|
499
560
|
const languageFeaturesService = accessor.get(ILanguageFeaturesService);
|
|
500
561
|
const logService = accessor.get(ILogService);
|
|
@@ -505,10 +566,10 @@ class CodeActionParticipantUtils {
|
|
|
505
566
|
_report() {
|
|
506
567
|
progress.report({
|
|
507
568
|
message: ( localize(
|
|
508
|
-
|
|
569
|
+
9663,
|
|
509
570
|
"Getting code actions from '{0}' ([configure]({1})).",
|
|
510
|
-
( [...this._names].map(name => `'${name}'`)).join(
|
|
511
|
-
|
|
571
|
+
( [...this._names].map(name => `'${name}'`)).join(", "),
|
|
572
|
+
"command:workbench.action.openSettings?%5B%22notebook.defaultFormatter%22%5D"
|
|
512
573
|
))
|
|
513
574
|
});
|
|
514
575
|
}
|
|
@@ -518,10 +579,19 @@ class CodeActionParticipantUtils {
|
|
|
518
579
|
this._report();
|
|
519
580
|
}
|
|
520
581
|
}
|
|
521
|
-
});
|
|
522
|
-
const providedActions = await CodeActionParticipantUtils.getActionsToRun(
|
|
582
|
+
})();
|
|
583
|
+
const providedActions = await CodeActionParticipantUtils.getActionsToRun(
|
|
584
|
+
model,
|
|
585
|
+
formatCodeActionOnSave,
|
|
586
|
+
excludes,
|
|
587
|
+
languageFeaturesService,
|
|
588
|
+
getActionProgress,
|
|
589
|
+
token
|
|
590
|
+
);
|
|
523
591
|
if (providedActions.validActions.length > 1 && !extensionId) {
|
|
524
|
-
logService.warn(
|
|
592
|
+
logService.warn(
|
|
593
|
+
"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."
|
|
594
|
+
);
|
|
525
595
|
}
|
|
526
596
|
if (token.isCancellationRequested) {
|
|
527
597
|
providedActions.dispose();
|
|
@@ -532,27 +602,38 @@ class CodeActionParticipantUtils {
|
|
|
532
602
|
if (!action) {
|
|
533
603
|
return false;
|
|
534
604
|
}
|
|
535
|
-
progress.report({
|
|
605
|
+
progress.report({
|
|
606
|
+
message: ( localize(9664, "Applying code action '{0}'.", action.action.title))
|
|
607
|
+
});
|
|
536
608
|
await instantiationService.invokeFunction(applyCodeAction, action, ApplyCodeActionReason.OnSave, {}, token);
|
|
537
609
|
if (token.isCancellationRequested) {
|
|
538
610
|
return false;
|
|
539
611
|
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
logService.error('Failed to apply notebook format code action on save');
|
|
612
|
+
} catch {
|
|
613
|
+
logService.error("Failed to apply notebook format code action on save");
|
|
543
614
|
return false;
|
|
544
|
-
}
|
|
545
|
-
finally {
|
|
615
|
+
} finally {
|
|
546
616
|
providedActions.dispose();
|
|
547
617
|
}
|
|
548
618
|
return true;
|
|
549
619
|
}
|
|
550
620
|
static getActionsToRun(model, codeActionKind, excludes, languageFeaturesService, progress, token) {
|
|
551
|
-
return getCodeActions(
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
621
|
+
return getCodeActions(
|
|
622
|
+
languageFeaturesService.codeActionProvider,
|
|
623
|
+
model,
|
|
624
|
+
model.getFullModelRange(),
|
|
625
|
+
{
|
|
626
|
+
type: CodeActionTriggerType.Invoke,
|
|
627
|
+
triggerAction: CodeActionTriggerSource.OnSave,
|
|
628
|
+
filter: {
|
|
629
|
+
include: codeActionKind,
|
|
630
|
+
excludes: excludes,
|
|
631
|
+
includeSourceActions: true
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
progress,
|
|
635
|
+
token
|
|
636
|
+
);
|
|
556
637
|
}
|
|
557
638
|
}
|
|
558
639
|
function getActiveCellCodeEditor(editorService) {
|
|
@@ -569,17 +650,24 @@ let SaveParticipantsContribution = class SaveParticipantsContribution extends Di
|
|
|
569
650
|
this.registerSaveParticipants();
|
|
570
651
|
}
|
|
571
652
|
registerSaveParticipants() {
|
|
572
|
-
this._register(
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
this._register(
|
|
576
|
-
|
|
653
|
+
this._register(
|
|
654
|
+
this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(TrimWhitespaceParticipant))
|
|
655
|
+
);
|
|
656
|
+
this._register(
|
|
657
|
+
this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(CodeActionOnSaveParticipant))
|
|
658
|
+
);
|
|
659
|
+
this._register(
|
|
660
|
+
this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(FormatOnSaveParticipant))
|
|
661
|
+
);
|
|
662
|
+
this._register(
|
|
663
|
+
this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(InsertFinalNewLineParticipant))
|
|
664
|
+
);
|
|
665
|
+
this._register(
|
|
666
|
+
this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(TrimFinalNewLinesParticipant))
|
|
667
|
+
);
|
|
577
668
|
}
|
|
578
669
|
};
|
|
579
|
-
SaveParticipantsContribution = ( __decorate([
|
|
580
|
-
( __param(0, IInstantiationService)),
|
|
581
|
-
( __param(1, IWorkingCopyFileService))
|
|
582
|
-
], SaveParticipantsContribution));
|
|
670
|
+
SaveParticipantsContribution = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, IWorkingCopyFileService))], SaveParticipantsContribution));
|
|
583
671
|
const workbenchContributionsRegistry = ( Registry.as(Extensions.Workbench));
|
|
584
672
|
workbenchContributionsRegistry.registerWorkbenchContribution(SaveParticipantsContribution, LifecyclePhase.Restored);
|
|
585
673
|
|