Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add an option for Escape key in Edit Mode to clear selection first, then switch to Command Mode #18206

Open
@i-aki-y

Description

@i-aki-y

Problem

Currently, pressing the Escape key while editing a cell immediately switches JupyterLab into Command Mode.
In many common editors, however, Escape is first used to clear any active cursor selection.
This difference can feel unintuitive: if a user has a selection active, pressing Escape may be expected to simply clear the selection rather than exit Edit Mode altogether.

Proposed Solution

  • When a selection is active, pressing Escape should clear the selection.
  • Only when no selection is active should Escape switch from Edit Mode to Command Mode.

One possible modification could be:
(jupyterlab/packages/codemirror/src/commands.ts)

export function simplifySelectionAndMaybeSwitchToCommandMode(target: {    dom: HTMLElement;    state: EditorState;    dispatch: (transaction: Transaction) => void;  }): boolean {    const arg = { state: target.state, dispatch: target.dispatch };    const preventDefault = simplifySelection(arg);-    if (target.dom.closest(ACTIVE_CELL_IN_EDIT_MODE_SELECTOR)) {+    if (!preventDefault && target.dom.closest(ACTIVE_CELL_IN_EDIT_MODE_SELECTOR)) {      // do not prevent default to allow switching to command mode      return false;    } else {      return preventDefault;    }  }

Note that the simplifySelection command returns false when the selection is already simple (i.e., no change was needed).

https://github.com/codemirror/commands/blob/6b76f57b07f115e604abf275d951b8f01d9ee982/src/commands.ts#L507-L517

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp