Skip to content

Commit f0edba3

Browse files
committed
1 parent 717181a commit f0edba3

File tree

3 files changed

+89
-24
lines changed

3 files changed

+89
-24
lines changed

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

+85-12
Original file line numberDiff line numberDiff line change
@@ -2066,15 +2066,31 @@ registerAction2(class NotebookConfigureLayoutAction extends Action2 {
20662066
category: NOTEBOOK_ACTIONS_CATEGORY,
20672067
menu: [
20682068
{
2069-
id: MenuId.NotebookEditorLayoutConfigure,
2069+
id: MenuId.NotebookToolbar,
20702070
group: 'notebookLayout',
2071-
when: NOTEBOOK_IS_ACTIVE_EDITOR,
2071+
when: ContextKeyExpr.equals('config.notebook.globalToolbar', true),
20722072
order: 1
2073-
},
2073+
}
2074+
]
2075+
});
2076+
}
2077+
run(accessor: ServicesAccessor): void {
2078+
accessor.get(IPreferencesService).openSettings({ jsonEditor: false, query: '@tag:notebookLayout' });
2079+
}
2080+
});
2081+
2082+
registerAction2(class NotebookConfigureLayoutFromEditorTitle extends Action2 {
2083+
constructor() {
2084+
super({
2085+
id: 'workbench.notebook.layout.configure.editorTitle',
2086+
title: localize('workbench.notebook.layout.configure.label', "Customize Notebook Layout"),
2087+
f1: true,
2088+
category: NOTEBOOK_ACTIONS_CATEGORY,
2089+
menu: [
20742090
{
2075-
id: MenuId.NotebookToolbar,
2091+
id: MenuId.NotebookEditorLayoutConfigure,
20762092
group: 'notebookLayout',
2077-
when: ContextKeyExpr.equals('config.notebook.globalToolbar', true),
2093+
when: NOTEBOOK_IS_ACTIVE_EDITOR,
20782094
order: 1
20792095
}
20802096
]
@@ -2095,13 +2111,70 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
20952111
when: NOTEBOOK_IS_ACTIVE_EDITOR
20962112
});
20972113

2098-
MenuRegistry.appendMenuItem(MenuId.NotebookEditorLayoutConfigure, {
2099-
command: {
2100-
id: 'breadcrumbs.toggle',
2101-
title: { value: localize('cmd.toggle', "Toggle Breadcrumbs"), original: 'Toggle Breadcrumbs' },
2102-
},
2103-
group: 'notebookLayoutDetails',
2104-
order: 2
2114+
registerAction2(class ToggleLineNumberFromEditorTitle extends Action2 {
2115+
constructor() {
2116+
super({
2117+
id: 'notebook.toggleLineNumbersFromEditorTitle',
2118+
title: { value: localize('notebook.toggleLineNumbers', "Toggle Notebook Line Numbers"), original: 'Toggle Notebook Line Numbers' },
2119+
precondition: NOTEBOOK_EDITOR_FOCUSED,
2120+
menu: [
2121+
{
2122+
id: MenuId.NotebookEditorLayoutConfigure,
2123+
group: 'notebookLayoutDetails',
2124+
order: 1,
2125+
when: NOTEBOOK_IS_ACTIVE_EDITOR
2126+
}],
2127+
category: NOTEBOOK_ACTIONS_CATEGORY,
2128+
f1: true,
2129+
toggled: {
2130+
condition: ContextKeyExpr.notEquals('config.notebook.lineNumbers', 'off'),
2131+
title: { value: localize('notebook.showLineNumbers', "Show Notebook Line Numbers"), original: 'Show Notebook Line Numbers' },
2132+
}
2133+
});
2134+
}
2135+
2136+
async run(accessor: ServicesAccessor): Promise<void> {
2137+
return accessor.get(ICommandService).executeCommand('notebook.toggleLineNumbers');
2138+
}
2139+
});
2140+
2141+
registerAction2(class ToggleCellToolbarPositionFromEditorTitle extends Action2 {
2142+
constructor() {
2143+
super({
2144+
id: 'notebook.toggleCellToolbarPositionFromEditorTitle',
2145+
title: { value: localize('notebook.toggleCellToolbarPosition', "Toggle Cell Toolbar Position"), original: 'Toggle Cell Toolbar Position' },
2146+
menu: [{
2147+
id: MenuId.NotebookEditorLayoutConfigure,
2148+
group: 'notebookLayoutDetails',
2149+
order: 3
2150+
}],
2151+
category: NOTEBOOK_ACTIONS_CATEGORY,
2152+
f1: false
2153+
});
2154+
}
2155+
2156+
async run(accessor: ServicesAccessor, ...args: any[]): Promise<void> {
2157+
return accessor.get(ICommandService).executeCommand('notebook.toggleCellToolbarPosition', ...args);
2158+
}
2159+
});
2160+
2161+
registerAction2(class ToggleBreadcrumbFromEditorTitle extends Action2 {
2162+
constructor() {
2163+
super({
2164+
id: 'breadcrumbs.toggleFromEditorTitle',
2165+
title: { value: localize('notebook.toggleBreadcrumb', "Toggle Breadcrumbs"), original: 'Toggle Breadcrumbs' },
2166+
menu: [{
2167+
id: MenuId.NotebookEditorLayoutConfigure,
2168+
group: 'notebookLayoutDetails',
2169+
order: 2
2170+
}],
2171+
f1: false
2172+
});
2173+
}
2174+
2175+
async run(accessor: ServicesAccessor): Promise<void> {
2176+
return accessor.get(ICommandService).executeCommand('breadcrumbs.toggle');
2177+
}
21052178
});
21062179

21072180
MenuRegistry.appendMenuItem(MenuId.NotebookToolbar, {

src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.ts

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export class ToggleCellToolbarPositionAction extends Action2 {
2121
id: MenuId.NotebookCellTitle,
2222
group: 'View',
2323
order: 1
24-
}, {
25-
id: MenuId.NotebookEditorLayoutConfigure,
26-
group: 'notebookLayoutDetails',
27-
order: 3
2824
}],
2925
category: NOTEBOOK_ACTIONS_CATEGORY,
3026
f1: false

src/vs/workbench/contrib/notebook/browser/view/renderers/cellEditorOptions.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import { Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'v
1414
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1515
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1616
import { Registry } from 'vs/platform/registry/common/platform';
17+
import { ActiveEditorContext } from 'vs/workbench/common/editor';
1718
import { NOTEBOOK_ACTIONS_CATEGORY } from 'vs/workbench/contrib/notebook/browser/contrib/coreActions';
18-
import { getNotebookEditorFromEditorPane, ICellViewModel, INotebookEditor, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
19+
import { getNotebookEditorFromEditorPane, ICellViewModel, INotebookEditor, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
20+
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
1921
import { NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
2022
import { NotebookOptions } from 'vs/workbench/contrib/notebook/common/notebookOptions';
2123
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -161,12 +163,6 @@ registerAction2(class ToggleLineNumberAction extends Action2 {
161163
title: { value: localize('notebook.toggleLineNumbers', "Toggle Notebook Line Numbers"), original: 'Toggle Notebook Line Numbers' },
162164
precondition: NOTEBOOK_EDITOR_FOCUSED,
163165
menu: [
164-
{
165-
id: MenuId.NotebookEditorLayoutConfigure,
166-
group: 'notebookLayoutDetails',
167-
order: 1,
168-
when: NOTEBOOK_IS_ACTIVE_EDITOR
169-
},
170166
{
171167
id: MenuId.NotebookToolbar,
172168
group: 'notebookLayout',
@@ -199,7 +195,7 @@ registerAction2(class ToggleActiveLineNumberAction extends Action2 {
199195
super({
200196
id: 'notebook.cell.toggleLineNumbers',
201197
title: 'Show Cell Line Numbers',
202-
precondition: NOTEBOOK_EDITOR_FOCUSED,
198+
precondition: ActiveEditorContext.isEqualTo(NotebookEditor.ID),
203199
menu: [{
204200
id: MenuId.NotebookCellTitle,
205201
group: 'View',

0 commit comments

Comments
 (0)