Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notebook cell editor navigate context keys to not override suggest widget #153736

Merged
merged 1 commit into from Jun 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { localize } from 'vs/nls';
import { registerAction2 } from 'vs/platform/actions/common/actions';
Expand All @@ -14,10 +15,9 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { INotebookActionContext, INotebookCellActionContext, NotebookAction, NotebookCellAction, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
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';
import { CellEditState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellKind, NOTEBOOK_EDITOR_CURSOR_BOUNDARY } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
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';

const NOTEBOOK_FOCUS_TOP = 'notebook.focusTop';
const NOTEBOOK_FOCUS_BOTTOM = 'notebook.focusBottom';
Expand All @@ -42,22 +42,27 @@ registerAction2(class FocusNextCellAction extends NotebookCellAction {
when: ContextKeyExpr.and(
NOTEBOOK_EDITOR_FOCUSED,
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
ContextKeyExpr.or(
ContextKeyExpr.and(
ContextKeyExpr.has(InputFocusedContextKey),
EditorContextKeys.editorTextFocus,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('top'),
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
),
ContextKeyExpr.and(
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
NOTEBOOK_CURSOR_NAVIGATION_MODE
)
)
ContextKeyExpr.and(
ContextKeyExpr.has(InputFocusedContextKey),
EditorContextKeys.editorTextFocus,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('top'),
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
),
),
primary: KeyCode.DownArrow,
weight: KeybindingWeight.WorkbenchContrib,
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, // code cell keybinding, focus inside editor: lower weight to not override suggest widget
},
{
when: ContextKeyExpr.and(
NOTEBOOK_EDITOR_FOCUSED,
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
ContextKeyExpr.and(
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
NOTEBOOK_CURSOR_NAVIGATION_MODE)
),
primary: KeyCode.DownArrow,
weight: KeybindingWeight.WorkbenchContrib, // markdown keybinding, focus on list: higher weight to override list.focusDown
},
{
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED),
Expand Down Expand Up @@ -95,27 +100,35 @@ registerAction2(class FocusPreviousCellAction extends NotebookCellAction {
super({
id: NOTEBOOK_FOCUS_PREVIOUS_EDITOR,
title: localize('cursorMoveUp', 'Focus Previous Cell Editor'),
keybinding: {
when: ContextKeyExpr.and(
NOTEBOOK_EDITOR_FOCUSED,
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
ContextKeyExpr.or(
keybinding: [
{
when: ContextKeyExpr.and(
NOTEBOOK_EDITOR_FOCUSED,
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
ContextKeyExpr.and(
ContextKeyExpr.has(InputFocusedContextKey),
EditorContextKeys.editorTextFocus,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('bottom'),
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
),
),
primary: KeyCode.UpArrow,
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, // code cell keybinding, focus inside editor: lower weight to not override suggest widget
},
{
when: ContextKeyExpr.and(
NOTEBOOK_EDITOR_FOCUSED,
ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true),
ContextKeyExpr.and(
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
NOTEBOOK_CURSOR_NAVIGATION_MODE
)
)
),
primary: KeyCode.UpArrow,
weight: KeybindingWeight.WorkbenchContrib,
},
),
primary: KeyCode.UpArrow,
weight: KeybindingWeight.WorkbenchContrib, // markdown keybinding, focus on list: higher weight to override list.focusDown
}
],
});
}

Expand Down