microsoft / microsoft/monaco-editor
[Bug] Visual highlighting issue for selected text when background has a set opacity
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!');
}`;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "javascript",
automaticLayout: true,
});
monaco.editor.defineTheme('default', {
base: 'vs',
inherit: true,
rules: [],
colors: {
'editor.background': '#00000000',
}
});
monaco.editor.setTheme('default')
Reproduction Steps
Set the background colour of the editor to #00000000 (transparent). This only occurs if the background is set to transparent (or if any opacity is set at all)
Highlight the text on the editor across at least 2 lines. The issue doesn't occur when highlighting on a single line and this occurs even without using a mouse and selecting text character by character.
Actual (Problematic) Behavior
Notice the caret positioning and the highlighted text does not match. What is accurate is the caret position (which determines the text being copied, and the highlighted selection does not reflect what is being selected)
Expected Behavior
The highlighting of the text selection should match the caret position when the background is transparent.
Additional Context
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 Monaco Editor Playground link and its embedded TypeScript example; reproduce a multi-line selection with editor.background set to #00000000 or another opacity. Done means the rendered selection highlight aligns with the caret and copied range. The payload names no source file or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100