microsoft / microsoft/monaco-editor
[Bug] Typing over a right-to-left selection requires two keypresses on the textarea input path (Safari)
@aiday-mar is already working on this.
Since Aug 14, 2026.
- 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
monaco.editor.create(document.getElementById("container"), {
value: "const U = 19.05;",
language: "typescript",
editContext: false, // Safari's path; omit this and use Safari instead
});
Reproduction Steps
Reproduces in any Chromium browser, which should make it easy to debug:
- Open the playground
- Click to place the caret at the very end of the line (right of
;). - Press Shift+Left once —
;is selected, backwards. - Press a once.
Then repeat with a right-to-left mouse drag, and with several characters
selected; the behavior is the same in all cases.
In Safari, do the same with default options (no editContext override).
Actual (Problematic) Behavior
Nothing happens. The selection remains and no text is inserted. Pressing a
a second time replaces the selection.
Expected Behavior
; is replaced, giving const U = 19.05a.
Additional Context
This affects Safari with default editor options, because Safari has no
EditContext support and therefore uses the legacy textarea input path
(editContextSupported: typeof globalThis.EditContext === 'function' is false).
The bug is not Safari-specific in nature: forcing the same path in Chromium with
editContext: false reproduces it there too, which suggests the problem is in
the textarea input pipeline rather than in WebKit.
Setting accessibilitySupport: "off" works around it completely. That switches
getScreenReaderContent() from SimplePagedScreenReaderStrategy to the macOS
branch that mirrors the selected text into the textarea and selects it
(new TextAreaState(text, 0, text.length, selection, 0) in
textAreaEditContext.ts), so the native replacement happens without any state
diffing. That points at the paged screen-reader content path as the source of
the problem, but it is not an acceptable general fix since it disables screen
reader support.
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.
Assessment
This issue has not been assessed yet.