Skip to content

[Bug] Typing with backward (RTL) selection fails when editContext: false #5207

@lindsbot

Description

@lindsbot

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.55.1#XQAAAAJyAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzfLcO_1uhs0-3YGTBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKimARHSWlrTPOQHROITHxmAetfeRrm3VHdSe7_Etv6WpgzlH4vE8EOEDMNvLzPHayHVIURO2M6qOjjOCBmDnp9jHpzW-FcCFVbyRo9s1yu9JcALg0-q4mS26nJaSDhuVeFsYGKO0Io6JDuxXgCYOTLCbhVeWicHHKc38WIrk2e5pQg4dDatl-PvOuuXTMg3Zd8-S0Rnc_6N7EkhE4UW13jxSA6H8c1HzrreiAjNnK1_BnKLlTHPFla17_8NmDyg

Monaco Editor Playground Code

const value = /* set from `myEditor.getModel()`: */ `function hello() {
	alert('Hello world!');
}`;

const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "javascript",
	automaticLayout: true,
	editContext: false // this causes the bug
});

Reproduction Steps

  1. Set editContext: false in editor config
  2. Select text in editor from right to left
  3. Type a single character to replace the selected text
  4. Observe: the character does not replace the text

Actual (Problematic) Behavior

RTL selections are not immediately replaced by a valid character, the first keypress is ignored.

Expected Behavior

The text replacement should occur immediately, after the first keypress, regardless of the selection direction.

Additional Context

editContext: false is a necessary workaround for #5081. Users who need that fix now hit this RTL bug.

Workaround

Intercept keydown and use editor.trigger() for RTL selections

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions