Skip to content

Commit a7002f6

Browse files
authored
Use NotebookOptions for statusbar instead of viewmodel options (microsoft#205791)
fix nb indentation actions + get nb options instead of textmodel options for statusbar
1 parent a1e1ff6 commit a7002f6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,11 @@ export class NotebookIndentationStatus extends Disposable implements IWorkbenchC
303303
this._accessor.clear();
304304
return;
305305
}
306-
const indentSize = cellOptions?.indentSize;
307-
const tabSize = cellOptions?.tabSize;
308-
const insertSpaces = cellOptions?.insertSpaces;
306+
307+
const cellEditorOverridesRaw = editor.notebookOptions.getDisplayOptions().editorOptionsCustomizations;
308+
const indentSize = cellEditorOverridesRaw['editor.indentSize'] ?? cellOptions?.indentSize;
309+
const insertSpaces = cellEditorOverridesRaw['editor.insertSpaces'] ?? cellOptions?.tabSize;
310+
const tabSize = cellEditorOverridesRaw['editor.tabSize'] ?? cellOptions?.insertSpaces;
309311

310312
const width = typeof indentSize === 'number' ? indentSize : tabSize;
311313

src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class NotebookIndentUsingTabs extends Action2 {
2424

2525
constructor() {
2626
super({
27-
id: NotebookIndentUsingSpaces.ID,
27+
id: NotebookIndentUsingTabs.ID,
2828
title: nls.localize('indentUsingTabs', "Indent Using Tabs"),
2929
precondition: undefined,
3030
});
@@ -56,7 +56,7 @@ export class NotebookChangeTabDisplaySize extends Action2 {
5656

5757
constructor() {
5858
super({
59-
id: NotebookIndentUsingSpaces.ID,
59+
id: NotebookChangeTabDisplaySize.ID,
6060
title: nls.localize('changeTabDisplaySize', "Change Tab Display Size"),
6161
precondition: undefined,
6262
});
@@ -72,15 +72,14 @@ export class NotebookIndentationToSpacesAction extends Action2 {
7272

7373
constructor() {
7474
super({
75-
id: NotebookIndentUsingSpaces.ID,
75+
id: NotebookIndentationToSpacesAction.ID,
7676
title: nls.localize('convertIndentationToSpaces', "Convert Indentation to Spaces"),
7777
precondition: undefined,
7878
});
7979
}
8080

8181
override run(accessor: ServicesAccessor, ...args: any[]): void {
8282
convertNotebookIndentation(accessor, true);
83-
8483
}
8584
}
8685

@@ -89,7 +88,7 @@ export class NotebookIndentationToTabsAction extends Action2 {
8988

9089
constructor() {
9190
super({
92-
id: NotebookIndentUsingSpaces.ID,
91+
id: NotebookIndentationToTabsAction.ID,
9392
title: nls.localize('convertIndentationToTabs', "Convert Indentation to Tabs"),
9493
precondition: undefined,
9594
});
@@ -194,8 +193,7 @@ function convertNotebookIndentation(accessor: ServicesAccessor, tabsToSpaces: bo
194193

195194
bulkEditService.apply(edits, { label: nls.localize('convertIndentation', "Convert Indentation"), code: 'undoredo.convertIndentation', });
196195

197-
})).then((notebookEdits) => {
198-
196+
})).then(() => {
199197
// store the initial values of the configuration
200198
const initialConfig = configurationService.getValue(NotebookSetting.cellEditorOptionsCustomizations) as any;
201199
const initialIndentSize = initialConfig['editor.indentSize'];
@@ -255,3 +253,7 @@ function getIndentationEditOperations(model: ITextModel, tabSize: number, tabsTo
255253
}
256254

257255
registerAction2(NotebookIndentUsingSpaces);
256+
registerAction2(NotebookIndentUsingTabs);
257+
registerAction2(NotebookChangeTabDisplaySize);
258+
registerAction2(NotebookIndentationToSpacesAction);
259+
registerAction2(NotebookIndentationToTabsAction);

0 commit comments

Comments
 (0)