@codingame/monaco-vscode-notebook-service-override 14.0.6 → 15.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 (110) hide show
  1. package/package.json +26 -29
  2. package/vscode/src/vs/editor/contrib/gotoError/browser/markerNavigationService.d.ts +34 -0
  3. package/vscode/src/vs/editor/contrib/gotoError/browser/markerNavigationService.js +216 -0
  4. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +8 -8
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +29 -28
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.d.ts +1 -1
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +3 -3
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +9 -9
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.d.ts +1 -1
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +5 -9
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.d.ts +1 -1
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +1 -1
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +5 -5
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/contribution.d.ts +1 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/contribution.js +10 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookCellDecorators.d.ts +4 -40
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookCellDecorators.js +13 -217
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.d.ts +3 -4
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.js +22 -33
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditController.d.ts +1 -1
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditController.js +17 -20
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.d.ts +2 -2
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.js +2 -2
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.d.ts +3 -1
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.js +8 -3
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.d.ts +6 -4
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.js +47 -29
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizerService.d.ts +5 -3
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizerService.js +28 -17
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.d.ts +2 -2
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +10 -10
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +1 -1
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.d.ts +1 -1
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +4 -4
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +1 -1
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +13 -13
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.d.ts +1 -1
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +1 -1
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +7 -7
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +12 -11
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +4 -4
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +2 -2
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +4 -3
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.d.ts +3 -3
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +14 -18
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +1 -1
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +18 -18
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.d.ts +11 -4
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +328 -116
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +3 -3
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +2 -2
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.d.ts +1 -2
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +8 -10
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.d.ts +5 -5
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +16 -16
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.d.ts +2 -2
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +19 -18
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.d.ts +1 -1
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +5 -5
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +1 -1
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +4 -4
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.d.ts +3 -5
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +39 -37
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +99 -8
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +40 -35
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +31 -31
  69. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +2 -2
  70. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +37 -33
  71. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +22 -25
  72. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +11 -10
  73. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.d.ts +2 -2
  74. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +17 -17
  75. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +4 -4
  76. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +58 -25
  77. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.d.ts +1 -1
  78. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +99 -87
  79. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +12 -12
  80. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +3 -3
  81. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +33 -33
  82. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.d.ts +6 -4
  83. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +7 -4
  84. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.d.ts +1 -1
  85. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +2 -2
  86. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.d.ts +1 -1
  87. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -1
  88. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +1 -1
  89. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +4 -4
  90. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +1 -1
  91. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.d.ts +3 -3
  92. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +8 -5
  93. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.d.ts +1 -1
  94. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +1 -1
  95. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.d.ts +5 -5
  96. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +2 -3
  97. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.d.ts +1 -1
  98. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.d.ts +3 -3
  99. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +5 -5
  100. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
  101. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.d.ts +1 -1
  102. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +3 -1
  103. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +20 -16
  104. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.d.ts +1 -1
  105. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.d.ts +2 -2
  106. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +14 -14
  107. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.d.ts +1 -1
  108. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +3 -3
  109. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.d.ts +2 -2
  110. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +2 -2
@@ -1,32 +1,30 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { CancellationTokenSource, CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
3
+ import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
4
4
  import { onUnexpectedExternalError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
5
5
  import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
6
6
  import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
7
  import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
8
8
  import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
9
- import { format, noBreakWhitespace } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
10
- import { Constants } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uint';
9
+ import { format } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
10
+ import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
11
11
  import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
12
- import { InjectedTextCursorStops } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
13
- import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures';
12
+ import { StandardTokenType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/encodedTokenAttributes';
13
+ import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
14
14
  import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
15
15
  import { registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
16
16
  import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
17
+ import { createInlineValueDecoration } from '@codingame/monaco-vscode-88aa9a78-75f5-5aaa-89e9-bbdd580b3b5c-common/vscode/vs/workbench/contrib/debug/browser/debugEditorContribution';
17
18
  import { State } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/debug/common/debug';
18
19
  import { IDebugService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/debug/common/debug.service';
19
20
  import { NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
20
- import { NotebookExecutionType } from '@codingame/monaco-vscode-af5ccfda-af82-504b-b365-92b4e654e5c5-common/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
21
+ import { NotebookExecutionType } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
21
22
  import { INotebookExecutionStateService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service';
22
23
  import { INotebookKernelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
23
- import { NotebookAction } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
24
- import { registerNotebookContribution } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
24
+ import { NotebookAction } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
25
+ import { registerNotebookContribution } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
25
26
 
26
- const MAX_INLINE_DECORATOR_LENGTH = 150;
27
- const variableRegex = ( new RegExp(
28
- '(?:[a-zA-Z_][a-zA-Z0-9_]*\\.)*' +
29
- '[a-zA-Z_][a-zA-Z0-9_]*', 'g'));
27
+ var NotebookInlineVariablesController_1;
30
28
  class InlineSegment {
31
29
  constructor(column, text) {
32
30
  this.column = column;
@@ -34,7 +32,9 @@ class InlineSegment {
34
32
  }
35
33
  }
36
34
  let NotebookInlineVariablesController = class NotebookInlineVariablesController extends Disposable {
35
+ static { NotebookInlineVariablesController_1 = this; }
37
36
  static { this.id = 'notebook.inlineVariablesController'; }
37
+ static { this.MAX_CELL_LINES = 5000; }
38
38
  constructor(notebookEditor, notebookKernelService, notebookExecutionStateService, languageFeaturesService, configurationService, debugService) {
39
39
  super();
40
40
  this.notebookEditor = notebookEditor;
@@ -47,7 +47,8 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
47
47
  this.cellContentListeners = ( new ResourceMap());
48
48
  this.currentCancellationTokenSources = ( new ResourceMap());
49
49
  this._register(this.notebookExecutionStateService.onDidChangeExecution(async (e) => {
50
- if (!this.configurationService.getValue(NotebookSetting.notebookInlineValues)) {
50
+ const inlineValuesSetting = this.configurationService.getValue(NotebookSetting.notebookInlineValues);
51
+ if (inlineValuesSetting === 'off') {
51
52
  return;
52
53
  }
53
54
  if (e.type === NotebookExecutionType.cell) {
@@ -56,7 +57,7 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
56
57
  }));
57
58
  this._register(Event.runAndSubscribe(this.configurationService.onDidChangeConfiguration, e => {
58
59
  if (!e || e.affectsConfiguration(NotebookSetting.notebookInlineValues)) {
59
- if (!this.configurationService.getValue(NotebookSetting.notebookInlineValues)) {
60
+ if (this.configurationService.getValue(NotebookSetting.notebookInlineValues) === 'off') {
60
61
  this.clearNotebookInlineDecorations();
61
62
  }
62
63
  }
@@ -87,9 +88,14 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
87
88
  if (!model) {
88
89
  return;
89
90
  }
91
+ const inlineValuesSetting = this.configurationService.getValue(NotebookSetting.notebookInlineValues);
92
+ const hasInlineValueProvider = ( this.languageFeaturesService.inlineValuesProvider.has(model));
93
+ if (inlineValuesSetting === 'off' || (inlineValuesSetting === 'auto' && !hasInlineValueProvider)) {
94
+ return;
95
+ }
90
96
  this.clearCellInlineDecorations(cell);
91
97
  const inlineDecorations = [];
92
- if (( this.languageFeaturesService.inlineValuesProvider.has(model))) {
98
+ if (hasInlineValueProvider) {
93
99
  const lastLine = model.getLineCount();
94
100
  const lastColumn = model.getLineMaxColumn(lastLine);
95
101
  const ctx = {
@@ -100,54 +106,57 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
100
106
  const lineDecorations = ( new Map());
101
107
  const fullCellRange = ( new Range(1, 1, lastLine, lastColumn));
102
108
  const promises = providers.flatMap(provider => Promise.resolve(provider.provideInlineValues(model, fullCellRange, ctx, token)).then(async (result) => {
103
- if (result) {
104
- let kernel;
105
- const kernelVars = [];
106
- if (( result.some(iv => iv.type === 'variable'))) {
107
- if (!this.notebookEditor.hasModel()) {
108
- return;
109
- }
110
- kernel = this.notebookKernelService.getMatchingKernel(this.notebookEditor.textModel);
111
- const variables = kernel.selected?.provideVariables(event.notebook, undefined, 'named', 0, token);
112
- if (!variables) {
113
- return;
114
- }
109
+ if (!result) {
110
+ return;
111
+ }
112
+ const notebook = this.notebookEditor.textModel;
113
+ if (!notebook) {
114
+ return;
115
+ }
116
+ const kernel = this.notebookKernelService.getMatchingKernel(notebook);
117
+ const kernelVars = [];
118
+ if (( result.some(iv => iv.type === 'variable'))) {
119
+ if (!this.notebookEditor.hasModel()) {
120
+ return;
121
+ }
122
+ const variables = kernel.selected?.provideVariables(event.notebook, undefined, 'named', 0, token);
123
+ if (variables) {
115
124
  for await (const v of variables) {
116
125
  kernelVars.push(v);
117
126
  }
118
127
  }
119
- for (const iv of result) {
120
- let text = undefined;
121
- switch (iv.type) {
122
- case 'text':
123
- text = iv.text;
124
- break;
125
- case 'variable': {
126
- const name = iv.variableName;
127
- if (!name) {
128
- continue;
129
- }
130
- const value = kernelVars.find(v => v.name === name)?.value;
131
- if (!value) {
132
- continue;
133
- }
134
- text = format('{0} = {1}', name, value);
135
- break;
128
+ }
129
+ for (const iv of result) {
130
+ let text = undefined;
131
+ switch (iv.type) {
132
+ case 'text':
133
+ text = iv.text;
134
+ break;
135
+ case 'variable': {
136
+ const name = iv.variableName;
137
+ if (!name) {
138
+ continue;
136
139
  }
137
- case 'expression': {
140
+ const value = kernelVars.find(v => v.name === name)?.value;
141
+ if (!value) {
138
142
  continue;
139
143
  }
144
+ text = format('{0} = {1}', name, value);
145
+ break;
140
146
  }
141
- if (text) {
142
- const line = iv.range.startLineNumber;
143
- let lineSegments = lineDecorations.get(line);
144
- if (!lineSegments) {
145
- lineSegments = [];
146
- lineDecorations.set(line, lineSegments);
147
- }
148
- if (!( lineSegments.some(iv => iv.text === text))) {
149
- lineSegments.push(( new InlineSegment(iv.range.startColumn, text)));
150
- }
147
+ case 'expression': {
148
+ continue;
149
+ }
150
+ }
151
+ if (text) {
152
+ const line = iv.range.startLineNumber;
153
+ let lineSegments = lineDecorations.get(line);
154
+ if (!lineSegments) {
155
+ lineSegments = [];
156
+ lineDecorations.set(line, lineSegments);
157
+ }
158
+ if (!( lineSegments.some(iv => iv.text === text))) {
159
+ lineSegments.push(( new InlineSegment(iv.range.startColumn, text)));
151
160
  }
152
161
  }
153
162
  }
@@ -157,18 +166,28 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
157
166
  await Promise.all(promises);
158
167
  lineDecorations.forEach((segments, line) => {
159
168
  if (segments.length > 0) {
160
- segments = segments.sort((a, b) => a.column - b.column);
169
+ segments.sort((a, b) => a.column - b.column);
161
170
  const text = ( segments.map(s => s.text)).join(', ');
162
- inlineDecorations.push(...this.createNotebookInlineValueDecoration(line, text));
171
+ const editorWidth = cell.layoutInfo.editorWidth;
172
+ const fontInfo = cell.layoutInfo.fontInfo;
173
+ if (fontInfo && cell.textModel) {
174
+ const base = Math.floor((editorWidth - 50) / fontInfo.typicalHalfwidthCharacterWidth);
175
+ const lineLength = cell.textModel.getLineLength(line);
176
+ const available = Math.max(0, base - lineLength);
177
+ inlineDecorations.push(...createInlineValueDecoration(line, text, 'nb', undefined, available));
178
+ }
179
+ else {
180
+ inlineDecorations.push(...createInlineValueDecoration(line, text, 'nb'));
181
+ }
163
182
  }
164
183
  });
165
184
  }
166
- else {
185
+ else if (inlineValuesSetting === 'on') {
167
186
  if (!this.notebookEditor.hasModel()) {
168
187
  return;
169
188
  }
170
189
  const kernel = this.notebookKernelService.getMatchingKernel(this.notebookEditor.textModel);
171
- const variables = kernel?.selected?.provideVariables(event.notebook, undefined, 'named', 0, CancellationToken.None);
190
+ const variables = kernel?.selected?.provideVariables(event.notebook, undefined, 'named', 0, token);
172
191
  if (!variables) {
173
192
  return;
174
193
  }
@@ -181,24 +200,259 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
181
200
  if (!document) {
182
201
  return;
183
202
  }
184
- for (let i = 1; i <= document.getLineCount(); i++) {
185
- const line = document.getLineContent(i);
186
- if (line.trimStart().startsWith('#')) {
203
+ if (document.getLineCount() > NotebookInlineVariablesController_1.MAX_CELL_LINES) {
204
+ return;
205
+ }
206
+ const inlineDecorations = [];
207
+ const processedVars = ( new Set());
208
+ const functionRanges = this.getFunctionRanges(document);
209
+ const commentedRanges = this.getCommentedRanges(document);
210
+ const ignoredRanges = [...functionRanges, ...commentedRanges];
211
+ const lineDecorations = ( new Map());
212
+ for (const varName of varNames) {
213
+ if (( processedVars.has(varName))) {
187
214
  continue;
188
215
  }
189
- for (let match = variableRegex.exec(line); match; match = variableRegex.exec(line)) {
190
- const name = match[0];
191
- if (varNames.includes(name)) {
192
- const inlineVal = name + ' = ' + vars.find(v => v.name === name)?.value;
193
- inlineDecorations.push(...this.createNotebookInlineValueDecoration(i, inlineVal));
216
+ const regex = ( new RegExp(`\\b${varName}\\b(?!\\w)`, 'g'));
217
+ let lastMatchOutsideIgnored = null;
218
+ let foundMatch = false;
219
+ const lines = document.getValue().split('\n');
220
+ for (let lineNumber = lines.length - 1; lineNumber >= 0; lineNumber--) {
221
+ const line = lines[lineNumber];
222
+ let match;
223
+ while ((match = regex.exec(line)) !== null) {
224
+ const startIndex = match.index;
225
+ const pos = ( new Position(lineNumber + 1, startIndex + 1));
226
+ if (!this.isPositionInRanges(pos, ignoredRanges)) {
227
+ lastMatchOutsideIgnored = {
228
+ line: lineNumber + 1,
229
+ column: startIndex + 1
230
+ };
231
+ foundMatch = true;
232
+ break;
233
+ }
234
+ }
235
+ if (foundMatch) {
236
+ break;
194
237
  }
195
238
  }
239
+ if (lastMatchOutsideIgnored) {
240
+ const inlineVal = varName + ' = ' + vars.find(v => v.name === varName)?.value;
241
+ let lineSegments = lineDecorations.get(lastMatchOutsideIgnored.line);
242
+ if (!lineSegments) {
243
+ lineSegments = [];
244
+ lineDecorations.set(lastMatchOutsideIgnored.line, lineSegments);
245
+ }
246
+ if (!( lineSegments.some(iv => iv.text === inlineVal))) {
247
+ lineSegments.push(( new InlineSegment(lastMatchOutsideIgnored.column, inlineVal)));
248
+ }
249
+ }
250
+ processedVars.add(varName);
251
+ }
252
+ lineDecorations.forEach((segments, line) => {
253
+ if (segments.length > 0) {
254
+ segments.sort((a, b) => a.column - b.column);
255
+ const text = ( segments.map(s => s.text)).join(', ');
256
+ const editorWidth = cell.layoutInfo.editorWidth;
257
+ const fontInfo = cell.layoutInfo.fontInfo;
258
+ if (fontInfo && cell.textModel) {
259
+ const base = Math.floor((editorWidth - 50) / fontInfo.typicalHalfwidthCharacterWidth);
260
+ const lineLength = cell.textModel.getLineLength(line);
261
+ const available = Math.max(0, base - lineLength);
262
+ inlineDecorations.push(...createInlineValueDecoration(line, text, 'nb', undefined, available));
263
+ }
264
+ else {
265
+ inlineDecorations.push(...createInlineValueDecoration(line, text, 'nb'));
266
+ }
267
+ }
268
+ });
269
+ if (inlineDecorations.length > 0) {
270
+ this.updateCellInlineDecorations(cell, inlineDecorations);
271
+ this.initCellContentListener(cell);
196
272
  }
197
273
  }
198
- if (inlineDecorations.length > 0) {
199
- this.updateCellInlineDecorations(cell, inlineDecorations);
200
- this.initCellContentListener(cell);
274
+ }
275
+ getFunctionRanges(document) {
276
+ return document.getLanguageId() === 'python'
277
+ ? this.getPythonFunctionRanges(document.getValue())
278
+ : this.getBracedFunctionRanges(document.getValue());
279
+ }
280
+ getPythonFunctionRanges(code) {
281
+ const functionRanges = [];
282
+ const lines = code.split('\n');
283
+ let functionStartLine = -1;
284
+ let inFunction = false;
285
+ let pythonIndentLevel = -1;
286
+ const pythonFunctionDeclRegex = /^(\s*)(async\s+)?(?:def\s+\w+|class\s+\w+)\s*\([^)]*\)\s*:/;
287
+ for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
288
+ const line = lines[lineNumber];
289
+ const pythonMatch = line.match(pythonFunctionDeclRegex);
290
+ if (pythonMatch) {
291
+ if (inFunction) {
292
+ const currentIndent = pythonMatch[1].length;
293
+ if (currentIndent <= pythonIndentLevel) {
294
+ functionRanges.push(( new Range(functionStartLine + 1, 1, lineNumber, line.length + 1)));
295
+ inFunction = false;
296
+ }
297
+ }
298
+ if (!inFunction) {
299
+ inFunction = true;
300
+ functionStartLine = lineNumber;
301
+ pythonIndentLevel = pythonMatch[1].length;
302
+ }
303
+ continue;
304
+ }
305
+ if (inFunction) {
306
+ if (line.trim() === '') {
307
+ continue;
308
+ }
309
+ const currentIndent = line.match(/^\s*/)?.[0].length ?? 0;
310
+ if (currentIndent <= pythonIndentLevel) {
311
+ functionRanges.push(( new Range(functionStartLine + 1, 1, lineNumber, line.length + 1)));
312
+ inFunction = false;
313
+ pythonIndentLevel = -1;
314
+ }
315
+ }
316
+ }
317
+ if (inFunction) {
318
+ functionRanges.push(( new Range(functionStartLine + 1, 1, lines.length, lines[lines.length - 1].length + 1)));
319
+ }
320
+ return functionRanges;
321
+ }
322
+ getBracedFunctionRanges(code) {
323
+ const functionRanges = [];
324
+ const lines = code.split('\n');
325
+ let braceDepth = 0;
326
+ let functionStartLine = -1;
327
+ let inFunction = false;
328
+ const functionDeclRegex = /\b(?:function\s+\w+|(?:async\s+)?(?:\w+\s*=\s*)?\([^)]*\)\s*=>|class\s+\w+|(?:public|private|protected|static)?\s*\w+\s*\([^)]*\)\s*{)/;
329
+ for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
330
+ const line = lines[lineNumber];
331
+ for (const char of line) {
332
+ if (char === '{') {
333
+ if (!inFunction && functionDeclRegex.test(line)) {
334
+ inFunction = true;
335
+ functionStartLine = lineNumber;
336
+ }
337
+ braceDepth++;
338
+ }
339
+ else if (char === '}') {
340
+ braceDepth--;
341
+ if (braceDepth === 0 && inFunction) {
342
+ functionRanges.push(( new Range(functionStartLine + 1, 1, lineNumber + 1, line.length + 1)));
343
+ inFunction = false;
344
+ }
345
+ }
346
+ }
347
+ }
348
+ return functionRanges;
349
+ }
350
+ getCommentedRanges(document) {
351
+ return this._getCommentedRanges(document);
352
+ }
353
+ _getCommentedRanges(document) {
354
+ try {
355
+ return this.getCommentedRangesByAccurateTokenization(document);
356
+ }
357
+ catch (e) {
358
+ return this.getCommentedRangesByManualParsing(document);
359
+ }
360
+ }
361
+ getCommentedRangesByAccurateTokenization(document) {
362
+ const commentRanges = [];
363
+ const lineCount = document.getLineCount();
364
+ if (lineCount > NotebookInlineVariablesController_1.MAX_CELL_LINES) {
365
+ return commentRanges;
366
+ }
367
+ for (let lineNumber = 1; lineNumber <= lineCount; lineNumber++) {
368
+ if (!document.tokenization.hasAccurateTokensForLine(lineNumber)) {
369
+ document.tokenization.forceTokenization(lineNumber);
370
+ }
371
+ const lineTokens = document.tokenization.getLineTokens(lineNumber);
372
+ if (lineTokens.getCount() === 0) {
373
+ continue;
374
+ }
375
+ let startCharacter;
376
+ for (let tokenIndex = 0; tokenIndex < lineTokens.getCount(); tokenIndex++) {
377
+ const tokenType = lineTokens.getStandardTokenType(tokenIndex);
378
+ if (tokenType === StandardTokenType.Comment || tokenType === StandardTokenType.String || tokenType === StandardTokenType.RegEx) {
379
+ if (startCharacter === undefined) {
380
+ startCharacter = lineTokens.getStartOffset(tokenIndex);
381
+ }
382
+ const endCharacter = lineTokens.getEndOffset(tokenIndex);
383
+ const isLastToken = tokenIndex === lineTokens.getCount() - 1;
384
+ const nextTokenDifferent = !isLastToken &&
385
+ lineTokens.getStandardTokenType(tokenIndex + 1) !== tokenType;
386
+ if (isLastToken || nextTokenDifferent) {
387
+ commentRanges.push(( new Range(lineNumber, startCharacter + 1, lineNumber, endCharacter + 1)));
388
+ startCharacter = undefined;
389
+ }
390
+ }
391
+ else {
392
+ startCharacter = undefined;
393
+ }
394
+ }
395
+ }
396
+ return commentRanges;
397
+ }
398
+ getCommentedRangesByManualParsing(document) {
399
+ const commentRanges = [];
400
+ const lines = document.getValue().split('\n');
401
+ const languageId = document.getLanguageId();
402
+ const lineCommentToken = languageId === 'python' ? '#' :
403
+ languageId === 'javascript' || languageId === 'typescript' ? '//' :
404
+ null;
405
+ const blockComments = (languageId === 'javascript' || languageId === 'typescript') ? { start: '/*', end: '*/' } :
406
+ null;
407
+ let inBlockComment = false;
408
+ let blockCommentStartLine = -1;
409
+ let blockCommentStartCol = -1;
410
+ for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
411
+ const line = lines[lineNumber];
412
+ const trimmedLine = line.trim();
413
+ if (trimmedLine.length === 0) {
414
+ continue;
415
+ }
416
+ if (blockComments) {
417
+ if (!inBlockComment) {
418
+ const startIndex = line.indexOf(blockComments.start);
419
+ if (startIndex !== -1) {
420
+ inBlockComment = true;
421
+ blockCommentStartLine = lineNumber;
422
+ blockCommentStartCol = startIndex;
423
+ }
424
+ }
425
+ if (inBlockComment) {
426
+ const endIndex = line.indexOf(blockComments.end);
427
+ if (endIndex !== -1) {
428
+ commentRanges.push(( new Range(
429
+ blockCommentStartLine + 1,
430
+ blockCommentStartCol + 1,
431
+ lineNumber + 1,
432
+ endIndex + blockComments.end.length + 1
433
+ )));
434
+ inBlockComment = false;
435
+ }
436
+ continue;
437
+ }
438
+ }
439
+ if (!inBlockComment && lineCommentToken && line.trimLeft().startsWith(lineCommentToken)) {
440
+ const startCol = line.indexOf(lineCommentToken);
441
+ commentRanges.push(( new Range(lineNumber + 1, startCol + 1, lineNumber + 1, line.length + 1)));
442
+ }
201
443
  }
444
+ if (inBlockComment) {
445
+ commentRanges.push(( new Range(
446
+ blockCommentStartLine + 1,
447
+ blockCommentStartCol + 1,
448
+ lines.length,
449
+ lines[lines.length - 1].length + 1
450
+ )));
451
+ }
452
+ return commentRanges;
453
+ }
454
+ isPositionInRanges(position, ranges) {
455
+ return ( ranges.some(range => range.containsPosition(position)));
202
456
  }
203
457
  updateCellInlineDecorations(cell, decorations) {
204
458
  const oldDecorations = this.cellDecorationIds.get(cell) ?? [];
@@ -233,58 +487,16 @@ let NotebookInlineVariablesController = class NotebookInlineVariablesController
233
487
  clearNotebookInlineDecorations() {
234
488
  this._clearNotebookInlineDecorations();
235
489
  }
236
- createNotebookInlineValueDecoration(lineNumber, contentText, column = Constants.MAX_SAFE_SMALL_INTEGER) {
237
- if (contentText.length > MAX_INLINE_DECORATOR_LENGTH) {
238
- contentText = contentText.substring(0, MAX_INLINE_DECORATOR_LENGTH) + '...';
239
- }
240
- return [
241
- {
242
- range: {
243
- startLineNumber: lineNumber,
244
- endLineNumber: lineNumber,
245
- startColumn: column,
246
- endColumn: column
247
- },
248
- options: {
249
- description: 'nb-inline-value-decoration-spacer',
250
- after: {
251
- content: noBreakWhitespace,
252
- cursorStops: InjectedTextCursorStops.None
253
- },
254
- showIfCollapsed: true,
255
- }
256
- },
257
- {
258
- range: {
259
- startLineNumber: lineNumber,
260
- endLineNumber: lineNumber,
261
- startColumn: column,
262
- endColumn: column
263
- },
264
- options: {
265
- description: 'nb-inline-value-decoration',
266
- after: {
267
- content: this.replaceWsWithNoBreakWs(contentText),
268
- inlineClassName: 'nb-inline-value',
269
- inlineClassNameAffectsLetterSpacing: true,
270
- cursorStops: InjectedTextCursorStops.None
271
- },
272
- showIfCollapsed: true,
273
- }
274
- },
275
- ];
276
- }
277
- replaceWsWithNoBreakWs(str) {
278
- return str.replace(/[ \t]/g, noBreakWhitespace);
279
- }
280
490
  dispose() {
281
491
  super.dispose();
282
492
  this._clearNotebookInlineDecorations();
283
493
  this.currentCancellationTokenSources.forEach(source => source.cancel());
284
494
  this.currentCancellationTokenSources.clear();
495
+ this.cellContentListeners.forEach(listener => listener.dispose());
496
+ this.cellContentListeners.clear();
285
497
  }
286
498
  };
287
- NotebookInlineVariablesController = ( __decorate([
499
+ NotebookInlineVariablesController = NotebookInlineVariablesController_1 = ( __decorate([
288
500
  ( __param(1, INotebookKernelService)),
289
501
  ( __param(2, INotebookExecutionStateService)),
290
502
  ( __param(3, ILanguageFeaturesService)),
@@ -296,7 +508,7 @@ registerAction2(class ClearNotebookInlineValues extends NotebookAction {
296
508
  constructor() {
297
509
  super({
298
510
  id: 'notebook.clearAllInlineValues',
299
- title: ( localize(7538, 'Clear All Inline Values')),
511
+ title: ( localize(7623, 'Clear All Inline Values')),
300
512
  });
301
513
  }
302
514
  runWithContext(accessor, context) {
@@ -11,8 +11,8 @@ import { IViewDescriptorService } from '@codingame/monaco-vscode-api/vscode/vs/w
11
11
  import { VIEWLET_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/debug/common/debug';
12
12
  import { NOTEBOOK_VARIABLE_VIEW_ENABLED } from './notebookVariableContextKeys.js';
13
13
  import { NotebookVariablesView } from './notebookVariablesView.js';
14
- import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
15
- import { variablesViewIcon } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
14
+ import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
15
+ import { variablesViewIcon } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
16
16
  import { NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
17
17
  import { INotebookExecutionStateService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service';
18
18
  import { INotebookKernelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookKernelService.service';
@@ -63,7 +63,7 @@ let NotebookVariables = class NotebookVariables extends Disposable {
63
63
  if (debugViewContainer) {
64
64
  const viewsRegistry = ( Registry.as(Extensions.ViewsRegistry));
65
65
  const viewDescriptor = {
66
- id: 'workbench.notebook.variables', name: ( localize2(7541, "Notebook Variables")),
66
+ id: 'workbench.notebook.variables', name: ( localize2(7626, "Notebook Variables")),
67
67
  containerIcon: variablesViewIcon, ctorDescriptor: ( new SyncDescriptor(NotebookVariablesView)),
68
68
  order: 50, weight: 5, canToggleVisibility: true, canMoveView: true, collapsed: false, when: NOTEBOOK_VARIABLE_VIEW_ENABLED
69
69
  };
@@ -78,7 +78,7 @@ class NotebookVariableDataSource {
78
78
  notebook: parent.notebook,
79
79
  id: parent.id + `${last + 1}`,
80
80
  extHostId: parent.extHostId,
81
- name: ( localize(7542, "Display limit reached")),
81
+ name: ( localize(7627, "Display limit reached")),
82
82
  value: '',
83
83
  indexedChildrenCount: 0,
84
84
  hasNamedChildren: false
@@ -56,10 +56,10 @@ NotebookVariableRenderer = NotebookVariableRenderer_1 = ( __decorate([
56
56
  ], NotebookVariableRenderer));
57
57
  class NotebookVariableAccessibilityProvider {
58
58
  getWidgetAriaLabel() {
59
- return localize(7543, "Notebook Variables");
59
+ return localize(7628, "Notebook Variables");
60
60
  }
61
61
  getAriaLabel(element) {
62
- return localize(7544, "Variable {0}, value {1}", element.name, element.value);
62
+ return localize(7629, "Variable {0}, value {1}", element.name, element.value);
63
63
  }
64
64
  }
65
65
 
@@ -9,7 +9,6 @@ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/pl
9
9
  import { IKeybindingService } from "@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service";
10
10
  import { IOpenerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service";
11
11
  import { IQuickInputService } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service";
12
- import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
13
12
  import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
14
13
  import { IViewPaneOptions, ViewPane } from "@codingame/monaco-vscode-65619f8f-0eab-5d8b-855a-43b6353fe527-common/vscode/vs/workbench/browser/parts/views/viewPane";
15
14
  import { IViewDescriptorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/views.service";
@@ -39,7 +38,7 @@ export declare class NotebookVariablesView extends ViewPane {
39
38
  private activeNotebook;
40
39
  private readonly dataSource;
41
40
  private updateScheduler;
42
- constructor(options: IViewPaneOptions, editorService: IEditorService, notebookKernelService: INotebookKernelService, notebookExecutionStateService: INotebookExecutionStateService, keybindingService: IKeybindingService, contextMenuService: IContextMenuService, contextKeyService: IContextKeyService, configurationService: IConfigurationService, instantiationService: IInstantiationService, viewDescriptorService: IViewDescriptorService, openerService: IOpenerService, quickInputService: IQuickInputService, commandService: ICommandService, themeService: IThemeService, telemetryService: ITelemetryService, hoverService: IHoverService, menuService: IMenuService);
41
+ constructor(options: IViewPaneOptions, editorService: IEditorService, notebookKernelService: INotebookKernelService, notebookExecutionStateService: INotebookExecutionStateService, keybindingService: IKeybindingService, contextMenuService: IContextMenuService, contextKeyService: IContextKeyService, configurationService: IConfigurationService, instantiationService: IInstantiationService, viewDescriptorService: IViewDescriptorService, openerService: IOpenerService, quickInputService: IQuickInputService, commandService: ICommandService, themeService: IThemeService, hoverService: IHoverService, menuService: IMenuService);
43
42
  protected renderBody(container: HTMLElement): void;
44
43
  private onContextMenu;
45
44
  focus(): void;