@codingame/monaco-vscode-notebook-service-override 9.0.2 → 10.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.
Files changed (60) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +16 -19
  3. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +62 -63
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +4 -6
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +5 -5
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +8 -9
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +35 -37
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +1 -2
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +1 -2
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +2 -2
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +16 -17
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +17 -20
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +15 -18
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +4 -6
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +1 -2
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +1 -1
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +319 -67
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +64 -61
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +2 -2
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +10 -9
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +48 -24
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +35 -37
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +45 -31
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +4 -5
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +2 -2
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +124 -71
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +179 -7
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +52 -55
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +30 -32
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +28 -30
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +17 -18
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +7 -7
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +20 -22
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +126 -46
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +171 -83
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +19 -19
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +5 -6
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +33 -33
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +4 -5
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +1 -1
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +6 -6
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +7 -8
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +3 -5
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +6 -9
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +1 -1
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +13 -21
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +90 -39
  52. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +3 -5
  53. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +40 -31
  54. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +7 -7
  55. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +10 -11
  56. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +29 -55
  57. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +15 -17
  58. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +12 -14
  59. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +2 -4
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +0 -33
@@ -1,5 +1,5 @@
1
1
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
2
- import { KeyCode, KeyMod, KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
2
+ import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
3
3
  import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
4
4
  import { localize2, localize } from 'vscode/vscode/vs/nls';
5
5
  import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
@@ -8,21 +8,24 @@ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/comma
8
8
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
9
9
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
10
10
  import { InputFocusedContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
11
- import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
12
- import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_RESPONSE_TYPE, InlineChatResponseType } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
11
+ import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_RESPONSE_TYPE, CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_DOCUMENT_CHANGED, CTX_INLINE_CHAT_EDIT_MODE, MENU_INLINE_CHAT_WIDGET_STATUS, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
13
12
  import { CTX_NOTEBOOK_CELL_CHAT_FOCUSED, MENU_CELL_CHAT_INPUT, CTX_NOTEBOOK_CHAT_HAS_ACTIVE_REQUEST, MENU_CELL_CHAT_WIDGET, CTX_NOTEBOOK_CHAT_USER_DID_EDIT, CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION, MENU_CELL_CHAT_WIDGET_STATUS, CTX_NOTEBOOK_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext';
14
13
  import { NotebookChatController } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController';
15
- import { NotebookAction, NotebookCellAction, getEditorFromArgsOrActivePane, CELL_TITLE_CELL_GROUP_ID } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
14
+ import { NotebookAction, NotebookCellAction, getEditorFromArgsOrActivePane, CELL_TITLE_CELL_GROUP_ID, getContextFromActiveEditor } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
16
15
  import { insertNewCell } from '../insertCellActions.js';
17
16
  import { CellEditState } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
18
17
  import { CellKind, NOTEBOOK_EDITOR_CURSOR_BOUNDARY, NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
19
- import { NOTEBOOK_CELL_EDITOR_FOCUSED, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_GENERATED_BY_CHAT } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
18
+ import { NOTEBOOK_CELL_EDITOR_FOCUSED, NOTEBOOK_EDITOR_FOCUSED, IS_COMPOSITE_NOTEBOOK, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_GENERATED_BY_CHAT } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
19
+ import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
20
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
21
+ import { CONTEXT_CHAT_INPUT_HAS_TEXT } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
22
+ import { AbstractInlineChatAction } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
20
23
 
21
24
  registerAction2(class extends NotebookAction {
22
25
  constructor() {
23
26
  super({
24
27
  id: 'notebook.cell.chat.accept',
25
- title: ( localize2(10747, "Make Request")),
28
+ title: ( localize2(10833, "Make Request")),
26
29
  icon: Codicon.send,
27
30
  keybinding: {
28
31
  when: ( (ContextKeyExpr.and(
@@ -30,8 +33,8 @@ registerAction2(class extends NotebookAction {
30
33
  CTX_INLINE_CHAT_FOCUSED,
31
34
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate())
32
35
  ))),
33
- weight: KeybindingWeight.WorkbenchContrib,
34
- primary: KeyCode.Enter
36
+ weight: 200 ,
37
+ primary: 3
35
38
  },
36
39
  menu: {
37
40
  id: MENU_CELL_CHAT_INPUT,
@@ -50,7 +53,7 @@ registerAction2(class extends NotebookCellAction {
50
53
  constructor() {
51
54
  super({
52
55
  id: 'notebook.cell.chat.arrowOutUp',
53
- title: ( localize(10748, 'Cursor Up')),
56
+ title: ( localize(10834, 'Cursor Up')),
54
57
  keybinding: {
55
58
  when: ( (ContextKeyExpr.and(
56
59
  CTX_NOTEBOOK_CELL_CHAT_FOCUSED,
@@ -59,8 +62,8 @@ registerAction2(class extends NotebookCellAction {
59
62
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate()),
60
63
  (CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate())
61
64
  ))),
62
- weight: KeybindingWeight.EditorCore + 7,
63
- primary: KeyMod.CtrlCmd | KeyCode.UpArrow
65
+ weight: 0 + 7,
66
+ primary: 2048 | 16
64
67
  },
65
68
  f1: false
66
69
  });
@@ -85,7 +88,7 @@ registerAction2(class extends NotebookAction {
85
88
  constructor() {
86
89
  super({
87
90
  id: 'notebook.cell.chat.arrowOutDown',
88
- title: ( localize(10749, 'Cursor Down')),
91
+ title: ( localize(10835, 'Cursor Down')),
89
92
  keybinding: {
90
93
  when: ( (ContextKeyExpr.and(
91
94
  CTX_NOTEBOOK_CELL_CHAT_FOCUSED,
@@ -94,8 +97,8 @@ registerAction2(class extends NotebookAction {
94
97
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate()),
95
98
  (CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate())
96
99
  ))),
97
- weight: KeybindingWeight.EditorCore + 7,
98
- primary: KeyMod.CtrlCmd | KeyCode.DownArrow
100
+ weight: 0 + 7,
101
+ primary: 2048 | 18
99
102
  },
100
103
  f1: false
101
104
  });
@@ -108,7 +111,7 @@ registerAction2(class extends NotebookCellAction {
108
111
  constructor() {
109
112
  super({
110
113
  id: 'notebook.cell.focusChatWidget',
111
- title: ( localize(10750, 'Focus Chat Widget')),
114
+ title: ( localize(10836, 'Focus Chat Widget')),
112
115
  keybinding: {
113
116
  when: ( (ContextKeyExpr.and(
114
117
  NOTEBOOK_EDITOR_FOCUSED,
@@ -121,8 +124,8 @@ registerAction2(class extends NotebookCellAction {
121
124
  )),
122
125
  (EditorContextKeys.isEmbeddedDiffEditor.negate())
123
126
  ))),
124
- weight: KeybindingWeight.EditorCore + 7,
125
- primary: KeyMod.CtrlCmd | KeyCode.UpArrow
127
+ weight: 0 + 7,
128
+ primary: 2048 | 16
126
129
  },
127
130
  f1: false
128
131
  });
@@ -136,10 +139,9 @@ registerAction2(class extends NotebookCellAction {
136
139
  constructor() {
137
140
  super({
138
141
  id: 'notebook.cell.focusNextChatWidget',
139
- title: ( localize(10751, 'Focus Next Cell Chat Widget')),
142
+ title: ( localize(10837, 'Focus Next Cell Chat Widget')),
140
143
  keybinding: {
141
144
  when: ( (ContextKeyExpr.and(
142
- NOTEBOOK_EDITOR_FOCUSED,
143
145
  (CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
144
146
  (ContextKeyExpr.and(
145
147
  (ContextKeyExpr.has(InputFocusedContextKey)),
@@ -149,10 +151,17 @@ registerAction2(class extends NotebookCellAction {
149
151
  )),
150
152
  (EditorContextKeys.isEmbeddedDiffEditor.negate())
151
153
  ))),
152
- weight: KeybindingWeight.EditorCore + 7,
153
- primary: KeyMod.CtrlCmd | KeyCode.DownArrow
154
+ weight: 0 + 7,
155
+ primary: 2048 | 18
154
156
  },
155
- f1: false
157
+ f1: false,
158
+ precondition: ( (ContextKeyExpr.or( (ContextKeyExpr.and(
159
+ (IS_COMPOSITE_NOTEBOOK.negate()),
160
+ NOTEBOOK_CELL_EDITOR_FOCUSED
161
+ )), (ContextKeyExpr.and(
162
+ IS_COMPOSITE_NOTEBOOK,
163
+ (NOTEBOOK_CELL_EDITOR_FOCUSED.negate())
164
+ )))))
156
165
  });
157
166
  }
158
167
  async runWithContext(accessor, context) {
@@ -164,7 +173,7 @@ registerAction2(class extends NotebookAction {
164
173
  constructor() {
165
174
  super({
166
175
  id: 'notebook.cell.chat.stop',
167
- title: ( localize2(10752, "Stop Request")),
176
+ title: ( localize2(10838, "Stop Request")),
168
177
  icon: Codicon.debugStop,
169
178
  menu: {
170
179
  id: MENU_CELL_CHAT_INPUT,
@@ -183,7 +192,7 @@ registerAction2(class extends NotebookAction {
183
192
  constructor() {
184
193
  super({
185
194
  id: 'notebook.cell.chat.close',
186
- title: ( localize2(10753, "Close Chat")),
195
+ title: ( localize2(10839, "Close Chat")),
187
196
  icon: Codicon.close,
188
197
  menu: {
189
198
  id: MENU_CELL_CHAT_WIDGET,
@@ -201,10 +210,10 @@ registerAction2(class extends NotebookAction {
201
210
  constructor() {
202
211
  super({
203
212
  id: 'notebook.cell.chat.acceptChanges',
204
- title: ( localize2(10754, "Accept Changes")),
205
- shortTitle: ( localize(10755, 'Accept')),
213
+ title: ( localize2(10840, "Accept Changes")),
214
+ shortTitle: ( localize(10841, 'Accept')),
206
215
  icon: Codicon.check,
207
- tooltip: ( localize(10756, 'Accept Changes')),
216
+ tooltip: ( localize(10842, 'Accept Changes')),
208
217
  keybinding: [
209
218
  {
210
219
  when: ( (ContextKeyExpr.and(
@@ -212,8 +221,8 @@ registerAction2(class extends NotebookAction {
212
221
  CTX_INLINE_CHAT_FOCUSED,
213
222
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate())
214
223
  ))),
215
- weight: KeybindingWeight.EditorContrib + 10,
216
- primary: KeyMod.CtrlCmd | KeyCode.Enter,
224
+ weight: 100 + 10,
225
+ primary: 2048 | 3 ,
217
226
  },
218
227
  {
219
228
  when: ( (ContextKeyExpr.and(
@@ -222,8 +231,8 @@ registerAction2(class extends NotebookAction {
222
231
  CTX_NOTEBOOK_CHAT_USER_DID_EDIT,
223
232
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate())
224
233
  ))),
225
- weight: KeybindingWeight.EditorCore + 10,
226
- primary: KeyCode.Escape
234
+ weight: 0 + 10,
235
+ primary: 9
227
236
  },
228
237
  {
229
238
  when: ( (ContextKeyExpr.and(
@@ -232,8 +241,8 @@ registerAction2(class extends NotebookAction {
232
241
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate()),
233
242
  (CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION.isEqualTo('below'))
234
243
  ))),
235
- primary: KeyMod.CtrlCmd | KeyCode.Enter,
236
- weight: KeybindingWeight.WorkbenchContrib
244
+ primary: 2048 | 3 ,
245
+ weight: 200
237
246
  }
238
247
  ],
239
248
  menu: [
@@ -241,7 +250,7 @@ registerAction2(class extends NotebookAction {
241
250
  id: MENU_CELL_CHAT_WIDGET_STATUS,
242
251
  group: '0_main',
243
252
  order: 0,
244
- when: ( (CTX_INLINE_CHAT_RESPONSE_TYPE.notEqualsTo(InlineChatResponseType.Messages))),
253
+ when: ( (CTX_INLINE_CHAT_RESPONSE_TYPE.notEqualsTo("messages" ))),
245
254
  }
246
255
  ],
247
256
  f1: false
@@ -255,7 +264,7 @@ registerAction2(class extends NotebookAction {
255
264
  constructor() {
256
265
  super({
257
266
  id: 'notebook.cell.chat.discard',
258
- title: ( localize(10757, 'Discard')),
267
+ title: ( localize(10843, 'Discard')),
259
268
  icon: Codicon.discard,
260
269
  keybinding: {
261
270
  when: ( (ContextKeyExpr.and(
@@ -264,8 +273,8 @@ registerAction2(class extends NotebookAction {
264
273
  (CTX_NOTEBOOK_CHAT_USER_DID_EDIT.negate()),
265
274
  (NOTEBOOK_CELL_EDITOR_FOCUSED.negate())
266
275
  ))),
267
- weight: KeybindingWeight.EditorContrib,
268
- primary: KeyCode.Escape
276
+ weight: 100 ,
277
+ primary: 9
269
278
  },
270
279
  menu: {
271
280
  id: MENU_CELL_CHAT_WIDGET_STATUS,
@@ -282,11 +291,7 @@ registerAction2(class extends NotebookAction {
282
291
  async function startChat(accessor, context, index, input, autoSend, source) {
283
292
  const configurationService = accessor.get(IConfigurationService);
284
293
  const commandService = accessor.get(ICommandService);
285
- if (configurationService.getValue(NotebookSetting.cellChat)) {
286
- context.notebookEditor.focusContainer();
287
- NotebookChatController.get(context.notebookEditor)?.run(index, input, autoSend);
288
- }
289
- else if (configurationService.getValue(NotebookSetting.cellGenerate)) {
294
+ if (configurationService.getValue(NotebookSetting.cellGenerate) || configurationService.getValue(NotebookSetting.cellChat)) {
290
295
  const activeCell = context.notebookEditor.getActiveCell();
291
296
  const targetCell = activeCell?.getTextLength() === 0 && source !== 'insertToolbar' ? activeCell : (await insertNewCell(accessor, context, CellKind.Code, 'below'));
292
297
  if (targetCell) {
@@ -305,12 +310,12 @@ registerAction2(class extends NotebookAction {
305
310
  super({
306
311
  id: 'notebook.cell.chat.start',
307
312
  title: {
308
- value: '$(sparkle) ' + ( localize(10758, "Generate")),
313
+ value: '$(sparkle) ' + ( localize(10844, "Generate")),
309
314
  original: '$(sparkle) Generate',
310
315
  },
311
- tooltip: ( localize(10759, "Start Chat to Generate Code")),
316
+ tooltip: ( localize(10845, "Start Chat to Generate Code")),
312
317
  metadata: {
313
- description: ( localize(10759, "Start Chat to Generate Code")),
318
+ description: ( localize(10845, "Start Chat to Generate Code")),
314
319
  args: [
315
320
  {
316
321
  name: 'args',
@@ -344,9 +349,9 @@ registerAction2(class extends NotebookAction {
344
349
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellGenerate}`, true))
345
350
  ))
346
351
  ))),
347
- weight: KeybindingWeight.WorkbenchContrib,
348
- primary: KeyMod.CtrlCmd | KeyCode.KeyI,
349
- secondary: [KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyI)],
352
+ weight: 200 ,
353
+ primary: 2048 | 39 ,
354
+ secondary: [KeyChord(2048 | 41 , 39 )],
350
355
  },
351
356
  menu: [
352
357
  {
@@ -408,10 +413,10 @@ registerAction2(class extends NotebookAction {
408
413
  super({
409
414
  id: 'notebook.cell.chat.startAtTop',
410
415
  title: {
411
- value: '$(sparkle) ' + ( localize(10758, "Generate")),
416
+ value: '$(sparkle) ' + ( localize(10844, "Generate")),
412
417
  original: '$(sparkle) Generate',
413
418
  },
414
- tooltip: ( localize(10759, "Start Chat to Generate Code")),
419
+ tooltip: ( localize(10845, "Start Chat to Generate Code")),
415
420
  f1: false,
416
421
  menu: [
417
422
  {
@@ -431,15 +436,15 @@ registerAction2(class extends NotebookAction {
431
436
  });
432
437
  }
433
438
  async runWithContext(accessor, context) {
434
- await startChat(accessor, context, 0, '', false);
439
+ await startChat(accessor, context);
435
440
  }
436
441
  });
437
442
  MenuRegistry.appendMenuItem(MenuId.NotebookToolbar, {
438
443
  command: {
439
444
  id: 'notebook.cell.chat.start',
440
445
  icon: Codicon.sparkle,
441
- title: ( localize(10760, "Generate")),
442
- tooltip: ( localize(10761, "Start Chat to Generate Code"))
446
+ title: ( localize(10846, "Generate")),
447
+ tooltip: ( localize(10847, "Start Chat to Generate Code"))
443
448
  },
444
449
  order: -10,
445
450
  group: 'navigation/add',
@@ -458,7 +463,7 @@ registerAction2(class extends NotebookAction {
458
463
  constructor() {
459
464
  super({
460
465
  id: 'notebook.cell.chat.focus',
461
- title: ( localize(10762, 'Focus Chat')),
466
+ title: ( localize(10848, 'Focus Chat')),
462
467
  keybinding: [
463
468
  {
464
469
  when: ( (ContextKeyExpr.and(
@@ -466,8 +471,8 @@ registerAction2(class extends NotebookAction {
466
471
  ContextKeyExpr.not(InputFocusedContextKey),
467
472
  (CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION.isEqualTo('above'))
468
473
  ))),
469
- primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
470
- weight: KeybindingWeight.WorkbenchContrib
474
+ primary: 2048 | 18 ,
475
+ weight: 200
471
476
  },
472
477
  {
473
478
  when: ( (ContextKeyExpr.and(
@@ -475,8 +480,8 @@ registerAction2(class extends NotebookAction {
475
480
  ContextKeyExpr.not(InputFocusedContextKey),
476
481
  (CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION.isEqualTo('below'))
477
482
  ))),
478
- primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
479
- weight: KeybindingWeight.WorkbenchContrib
483
+ primary: 2048 | 16 ,
484
+ weight: 200
480
485
  }
481
486
  ],
482
487
  f1: false
@@ -490,12 +495,12 @@ registerAction2(class extends NotebookAction {
490
495
  constructor() {
491
496
  super({
492
497
  id: 'notebook.cell.chat.focusNextCell',
493
- title: ( localize(10763, 'Focus Next Cell')),
498
+ title: ( localize(10849, 'Focus Next Cell')),
494
499
  keybinding: [
495
500
  {
496
501
  when: ( (ContextKeyExpr.and(CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_INLINE_CHAT_FOCUSED))),
497
- primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
498
- weight: KeybindingWeight.WorkbenchContrib
502
+ primary: 2048 | 18 ,
503
+ weight: 200
499
504
  }
500
505
  ],
501
506
  f1: false
@@ -509,12 +514,12 @@ registerAction2(class extends NotebookAction {
509
514
  constructor() {
510
515
  super({
511
516
  id: 'notebook.cell.chat.focusPreviousCell',
512
- title: ( localize(10764, 'Focus Previous Cell')),
517
+ title: ( localize(10850, 'Focus Previous Cell')),
513
518
  keybinding: [
514
519
  {
515
520
  when: ( (ContextKeyExpr.and(CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_INLINE_CHAT_FOCUSED))),
516
- primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
517
- weight: KeybindingWeight.WorkbenchContrib
521
+ primary: 2048 | 16 ,
522
+ weight: 200
518
523
  }
519
524
  ],
520
525
  f1: false
@@ -528,12 +533,12 @@ registerAction2(class extends NotebookAction {
528
533
  constructor() {
529
534
  super({
530
535
  id: 'notebook.cell.chat.previousFromHistory',
531
- title: ( localize2(10765, "Previous From History")),
536
+ title: ( localize2(10851, "Previous From History")),
532
537
  precondition: ( (ContextKeyExpr.and(CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_INLINE_CHAT_FOCUSED))),
533
538
  keybinding: {
534
539
  when: ( (ContextKeyExpr.and(CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_INLINE_CHAT_FOCUSED))),
535
- weight: KeybindingWeight.EditorCore + 10,
536
- primary: KeyCode.UpArrow,
540
+ weight: 0 + 10,
541
+ primary: 16 ,
537
542
  },
538
543
  f1: false
539
544
  });
@@ -546,12 +551,12 @@ registerAction2(class extends NotebookAction {
546
551
  constructor() {
547
552
  super({
548
553
  id: 'notebook.cell.chat.nextFromHistory',
549
- title: ( localize2(10766, "Next From History")),
554
+ title: ( localize2(10852, "Next From History")),
550
555
  precondition: ( (ContextKeyExpr.and(CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_INLINE_CHAT_FOCUSED))),
551
556
  keybinding: {
552
557
  when: ( (ContextKeyExpr.and(CTX_NOTEBOOK_CELL_CHAT_FOCUSED, CTX_INLINE_CHAT_FOCUSED))),
553
- weight: KeybindingWeight.EditorCore + 10,
554
- primary: KeyCode.DownArrow
558
+ weight: 0 + 10,
559
+ primary: 18
555
560
  },
556
561
  f1: false
557
562
  });
@@ -564,7 +569,7 @@ registerAction2(class extends NotebookCellAction {
564
569
  constructor() {
565
570
  super({
566
571
  id: 'notebook.cell.chat.restore',
567
- title: ( localize2(10767, "Generate")),
572
+ title: ( localize2(10853, "Generate")),
568
573
  icon: Codicon.sparkle,
569
574
  menu: {
570
575
  id: MenuId.NotebookCellTitle,
@@ -596,3 +601,51 @@ registerAction2(class extends NotebookCellAction {
596
601
  }
597
602
  }
598
603
  });
604
+ class AcceptChangesAndRun extends AbstractInlineChatAction {
605
+ constructor() {
606
+ super({
607
+ id: 'notebook.inlineChat.acceptChangesAndRun',
608
+ title: ( localize2(10854, "Accept and Run")),
609
+ shortTitle: ( localize(10855, 'Accept & Run')),
610
+ tooltip: ( localize(10856, 'Accept the changes and run the cell')),
611
+ icon: Codicon.check,
612
+ f1: true,
613
+ precondition: ( (ContextKeyExpr.and(
614
+ (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
615
+ CTX_INLINE_CHAT_VISIBLE,
616
+ (ContextKeyExpr.or(
617
+ (CTX_INLINE_CHAT_DOCUMENT_CHANGED.toNegated()),
618
+ (CTX_INLINE_CHAT_EDIT_MODE.notEqualsTo("preview" ))
619
+ ))
620
+ ))),
621
+ keybinding: undefined,
622
+ menu: [{
623
+ id: MENU_INLINE_CHAT_WIDGET_STATUS,
624
+ group: '0_main',
625
+ order: 2,
626
+ when: ( (ContextKeyExpr.and(
627
+ (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
628
+ (CONTEXT_CHAT_INPUT_HAS_TEXT.toNegated()),
629
+ (CTX_INLINE_CHAT_REQUEST_IN_PROGRESS.toNegated()),
630
+ (CTX_INLINE_CHAT_RESPONSE_TYPE.isEqualTo("messagesAndEdits" ))
631
+ )))
632
+ }]
633
+ });
634
+ }
635
+ async runInlineChatCommand(accessor, ctrl, codeEditor, hunk) {
636
+ const editor = getContextFromActiveEditor(accessor.get(IEditorService));
637
+ if (!editor) {
638
+ return;
639
+ }
640
+ const matchedCell = editor.notebookEditor.codeEditors.find(e => e[1] === codeEditor);
641
+ const cell = matchedCell?.[0];
642
+ if (!cell) {
643
+ return;
644
+ }
645
+ ctrl.acceptSession();
646
+ return editor.notebookEditor.executeNotebookCells(Iterable.single(cell));
647
+ }
648
+ }
649
+ registerAction2(AcceptChangesAndRun);
650
+
651
+ export { AcceptChangesAndRun };
@@ -1,16 +1,37 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
3
+ import { codiconsLibrary } from 'vscode/vscode/vs/base/common/codiconsLibrary';
2
4
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
6
+ import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
7
+ import { localize } from 'vscode/vscode/vs/nls';
8
+ import { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
3
9
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
4
- import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
10
+ import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
11
+ import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
12
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
13
+ import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
14
+ import { ChatInputPart } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatInputPart';
15
+ import { ChatContextAttachments } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments';
16
+ import { ChatDynamicVariableModel } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
17
+ import { computeCompletionRanges } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions';
5
18
  import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
6
19
  import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
20
+ import { chatVariableLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
21
+ import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
22
+ import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
7
23
  import './cellChatActions.js';
8
24
  import { CTX_NOTEBOOK_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext';
9
25
 
26
+ const NotebookKernelVariableKey = 'kernelVariable';
10
27
  let NotebookChatContribution = class NotebookChatContribution extends Disposable {
11
28
  static { this.ID = 'workbench.contrib.notebookChatContribution'; }
12
- constructor(contextKeyService, chatAgentService) {
29
+ constructor(contextKeyService, chatAgentService, editorService, chatWidgetService, notebookKernelService, languageFeaturesService) {
13
30
  super();
31
+ this.editorService = editorService;
32
+ this.chatWidgetService = chatWidgetService;
33
+ this.notebookKernelService = notebookKernelService;
34
+ this.languageFeaturesService = languageFeaturesService;
14
35
  this._ctxHasProvider = CTX_NOTEBOOK_CHAT_HAS_AGENT.bindTo(contextKeyService);
15
36
  const updateNotebookAgentStatus = () => {
16
37
  const hasNotebookAgent = Boolean(chatAgentService.getDefaultAgent(ChatAgentLocation.Notebook));
@@ -18,10 +39,161 @@ let NotebookChatContribution = class NotebookChatContribution extends Disposable
18
39
  };
19
40
  updateNotebookAgentStatus();
20
41
  this._register(chatAgentService.onDidChangeAgents(updateNotebookAgentStatus));
42
+ this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
43
+ _debugDisplayName: 'chatKernelDynamicCompletions',
44
+ triggerCharacters: [chatVariableLeader],
45
+ provideCompletionItems: async (model, position, _context, token) => {
46
+ const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
47
+ if (!widget || !widget.supportsFileReferences) {
48
+ return null;
49
+ }
50
+ if (widget.location !== ChatAgentLocation.Notebook) {
51
+ return null;
52
+ }
53
+ const variableNameDef = ( (new RegExp(`${chatVariableLeader}\\w*`, 'g')));
54
+ const range = computeCompletionRanges(model, position, variableNameDef, true);
55
+ if (!range) {
56
+ return null;
57
+ }
58
+ const result = { suggestions: [] };
59
+ const afterRange = ( (new Range(
60
+ position.lineNumber,
61
+ range.replace.startColumn,
62
+ position.lineNumber,
63
+ range.replace.startColumn + `${chatVariableLeader}${NotebookKernelVariableKey}:`.length
64
+ )));
65
+ result.suggestions.push({
66
+ label: `${chatVariableLeader}${NotebookKernelVariableKey}`,
67
+ insertText: `${chatVariableLeader}${NotebookKernelVariableKey}:`,
68
+ detail: ( localize(8020, "Pick a variable from the kernel")),
69
+ range,
70
+ kind: 18 ,
71
+ command: { id: SelectAndInsertKernelVariableAction.ID, title: SelectAndInsertKernelVariableAction.ID, arguments: [{ widget, range: afterRange }] },
72
+ sortText: 'z'
73
+ });
74
+ await this.addKernelVariableCompletion(widget, result, range, token);
75
+ return result;
76
+ }
77
+ }));
78
+ }
79
+ async addKernelVariableCompletion(widget, result, info, token) {
80
+ let pattern;
81
+ if (info.varWord?.word && info.varWord.word.startsWith(chatVariableLeader)) {
82
+ pattern = info.varWord.word.toLowerCase().slice(1);
83
+ }
84
+ const notebook = getNotebookEditorFromEditorPane(this.editorService.activeEditorPane)?.getViewModel()?.notebookDocument;
85
+ if (!notebook) {
86
+ return;
87
+ }
88
+ const selectedKernel = this.notebookKernelService.getMatchingKernel(notebook).selected;
89
+ const hasVariableProvider = selectedKernel?.hasVariableProvider;
90
+ if (!hasVariableProvider) {
91
+ return;
92
+ }
93
+ const variables = await selectedKernel.provideVariables(notebook.uri, undefined, 'named', 0, CancellationToken.None);
94
+ for await (const variable of variables) {
95
+ if (pattern && !variable.name.toLowerCase().includes(pattern)) {
96
+ continue;
97
+ }
98
+ result.suggestions.push({
99
+ label: { label: variable.name, description: variable.type },
100
+ insertText: `${chatVariableLeader}${NotebookKernelVariableKey}:${variable.name} `,
101
+ filterText: `${chatVariableLeader}${variable.name}`,
102
+ range: info,
103
+ kind: 4 ,
104
+ sortText: 'z',
105
+ command: { id: SelectAndInsertKernelVariableAction.ID, title: SelectAndInsertKernelVariableAction.ID, arguments: [{ widget, range: info.insert, variable: variable.name }] },
106
+ detail: variable.type,
107
+ documentation: variable.value,
108
+ });
109
+ }
21
110
  }
22
111
  };
23
- NotebookChatContribution = ( __decorate([
24
- ( __param(0, IContextKeyService)),
25
- ( __param(1, IChatAgentService))
26
- ], NotebookChatContribution));
27
- registerWorkbenchContribution2(NotebookChatContribution.ID, NotebookChatContribution, WorkbenchPhase.BlockRestore);
112
+ NotebookChatContribution = ( (__decorate([
113
+ ( (__param(0, IContextKeyService))),
114
+ ( (__param(1, IChatAgentService))),
115
+ ( (__param(2, IEditorService))),
116
+ ( (__param(3, IChatWidgetService))),
117
+ ( (__param(4, INotebookKernelService))),
118
+ ( (__param(5, ILanguageFeaturesService)))
119
+ ], NotebookChatContribution)));
120
+ class SelectAndInsertKernelVariableAction extends Action2 {
121
+ constructor() {
122
+ super({
123
+ id: SelectAndInsertKernelVariableAction.ID,
124
+ title: ''
125
+ });
126
+ }
127
+ static { this.ID = 'notebook.chat.selectAndInsertKernelVariable'; }
128
+ async run(accessor, ...args) {
129
+ const editorService = accessor.get(IEditorService);
130
+ const notebookKernelService = accessor.get(INotebookKernelService);
131
+ const quickInputService = accessor.get(IQuickInputService);
132
+ const notebook = getNotebookEditorFromEditorPane(editorService.activeEditorPane)?.getViewModel()?.notebookDocument;
133
+ if (!notebook) {
134
+ return;
135
+ }
136
+ const context = args[0];
137
+ if (!context || !('widget' in context) || !('range' in context)) {
138
+ return;
139
+ }
140
+ const widget = context.widget;
141
+ const range = context.range;
142
+ const variable = context.variable;
143
+ if (variable !== undefined) {
144
+ this.addVariableReference(widget, variable, range, false);
145
+ return;
146
+ }
147
+ const selectedKernel = notebookKernelService.getMatchingKernel(notebook).selected;
148
+ const hasVariableProvider = selectedKernel?.hasVariableProvider;
149
+ if (!hasVariableProvider) {
150
+ return;
151
+ }
152
+ const variables = await selectedKernel.provideVariables(notebook.uri, undefined, 'named', 0, CancellationToken.None);
153
+ const quickPickItems = [];
154
+ for await (const variable of variables) {
155
+ quickPickItems.push({
156
+ label: variable.name,
157
+ description: variable.value,
158
+ detail: variable.type,
159
+ });
160
+ }
161
+ const pickedVariable = await quickInputService.pick(quickPickItems, { placeHolder: 'Select a kernel variable' });
162
+ if (!pickedVariable) {
163
+ return;
164
+ }
165
+ this.addVariableReference(widget, pickedVariable.label, range, true);
166
+ }
167
+ addVariableReference(widget, variableName, range, updateText) {
168
+ if (range) {
169
+ const text = `#kernelVariable:${variableName}`;
170
+ if (updateText) {
171
+ const editor = widget.inputEditor;
172
+ const success = editor.executeEdits('chatInsertFile', [{ range, text: text + ' ' }]);
173
+ if (!success) {
174
+ return;
175
+ }
176
+ }
177
+ widget.getContrib(ChatDynamicVariableModel.ID)?.addReference({
178
+ id: 'vscode.notebook.variable',
179
+ range: { startLineNumber: range.startLineNumber, startColumn: range.startColumn, endLineNumber: range.endLineNumber, endColumn: range.startColumn + text.length },
180
+ data: variableName,
181
+ fullName: variableName,
182
+ icon: codiconsLibrary.variable,
183
+ });
184
+ }
185
+ else {
186
+ widget.getContrib(ChatContextAttachments.ID)?.setContext(false, ...[{
187
+ id: 'vscode.notebook.variable',
188
+ name: variableName,
189
+ value: variableName,
190
+ icon: codiconsLibrary.variable,
191
+ isDynamic: true
192
+ }]);
193
+ }
194
+ }
195
+ }
196
+ registerAction2(SelectAndInsertKernelVariableAction);
197
+ registerWorkbenchContribution2(NotebookChatContribution.ID, NotebookChatContribution, 2 );
198
+
199
+ export { SelectAndInsertKernelVariableAction };