Skip to content

Commit 39a346c

Browse files
authored
Fix notebook cell editor navigate context keys to not override suggest widget (microsoft#153736)
Fixes microsoft#152770
1 parent 290210f commit 39a346c

File tree

1 file changed

+39
-26
lines changed
  • src/vs/workbench/contrib/notebook/browser/contrib/navigation

1 file changed

+39
-26
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.ts

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
7+
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
78
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
89
import { localize } from 'vs/nls';
910
import { registerAction2 } from 'vs/platform/actions/common/actions';
@@ -14,10 +15,9 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
1415
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1516
import { Registry } from 'vs/platform/registry/common/platform';
1617
import { INotebookActionContext, INotebookCellActionContext, NotebookAction, NotebookCellAction, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
17-
import { NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_TYPE, NOTEBOOK_CURSOR_NAVIGATION_MODE, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
1818
import { CellEditState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1919
import { CellKind, NOTEBOOK_EDITOR_CURSOR_BOUNDARY } from 'vs/workbench/contrib/notebook/common/notebookCommon';
20-
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
20+
import { NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_TYPE, NOTEBOOK_CURSOR_NAVIGATION_MODE, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
2121

2222
const NOTEBOOK_FOCUS_TOP = 'notebook.focusTop';
2323
const NOTEBOOK_FOCUS_BOTTOM = 'notebook.focusBottom';
@@ -42,22 +42,27 @@ registerAction2(class FocusNextCellAction extends NotebookCellAction {
4242
when: ContextKeyExpr.and(
4343
NOTEBOOK_EDITOR_FOCUSED,
4444
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
45-
ContextKeyExpr.or(
46-
ContextKeyExpr.and(
47-
ContextKeyExpr.has(InputFocusedContextKey),
48-
EditorContextKeys.editorTextFocus,
49-
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('top'),
50-
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
51-
),
52-
ContextKeyExpr.and(
53-
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
54-
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
55-
NOTEBOOK_CURSOR_NAVIGATION_MODE
56-
)
57-
)
45+
ContextKeyExpr.and(
46+
ContextKeyExpr.has(InputFocusedContextKey),
47+
EditorContextKeys.editorTextFocus,
48+
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('top'),
49+
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
50+
),
5851
),
5952
primary: KeyCode.DownArrow,
60-
weight: KeybindingWeight.WorkbenchContrib,
53+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, // code cell keybinding, focus inside editor: lower weight to not override suggest widget
54+
},
55+
{
56+
when: ContextKeyExpr.and(
57+
NOTEBOOK_EDITOR_FOCUSED,
58+
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
59+
ContextKeyExpr.and(
60+
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
61+
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
62+
NOTEBOOK_CURSOR_NAVIGATION_MODE)
63+
),
64+
primary: KeyCode.DownArrow,
65+
weight: KeybindingWeight.WorkbenchContrib, // markdown keybinding, focus on list: higher weight to override list.focusDown
6166
},
6267
{
6368
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED),
@@ -95,27 +100,35 @@ registerAction2(class FocusPreviousCellAction extends NotebookCellAction {
95100
super({
96101
id: NOTEBOOK_FOCUS_PREVIOUS_EDITOR,
97102
title: localize('cursorMoveUp', 'Focus Previous Cell Editor'),
98-
keybinding: {
99-
when: ContextKeyExpr.and(
100-
NOTEBOOK_EDITOR_FOCUSED,
101-
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
102-
ContextKeyExpr.or(
103+
keybinding: [
104+
{
105+
when: ContextKeyExpr.and(
106+
NOTEBOOK_EDITOR_FOCUSED,
107+
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
103108
ContextKeyExpr.and(
104109
ContextKeyExpr.has(InputFocusedContextKey),
105110
EditorContextKeys.editorTextFocus,
106111
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('bottom'),
107112
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
108113
),
114+
),
115+
primary: KeyCode.UpArrow,
116+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, // code cell keybinding, focus inside editor: lower weight to not override suggest widget
117+
},
118+
{
119+
when: ContextKeyExpr.and(
120+
NOTEBOOK_EDITOR_FOCUSED,
121+
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
109122
ContextKeyExpr.and(
110123
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
111124
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
112125
NOTEBOOK_CURSOR_NAVIGATION_MODE
113126
)
114-
)
115-
),
116-
primary: KeyCode.UpArrow,
117-
weight: KeybindingWeight.WorkbenchContrib,
118-
},
127+
),
128+
primary: KeyCode.UpArrow,
129+
weight: KeybindingWeight.WorkbenchContrib, // markdown keybinding, focus on list: higher weight to override list.focusDown
130+
}
131+
],
119132
});
120133
}
121134

0 commit comments

Comments
 (0)