microsoft / microsoft/monaco-editor
[Bug] Typing with backward (RTL) selection fails when editContext: false
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
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
- Set
editContext: falsein editor config - Select text in editor from right to left
- Type a single character to replace the selected text
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Monaco Editor Playground and reproduce the issue using the provided editor configuration with editContext: false. Compare right-to-left and left-to-right selections, then trace the editor's selection and keypress handling for this setting. Done means the first typed character immediately replaces the selected text in both directions without requiring the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100