microsoft / microsoft/monaco-editor

[Bug] Visual highlighting issue for selected text when background has a set opacity

Open
#4,158 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug editor-core
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?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.41.0#XQAAAAIzAgAAAAAAAABBqQkHQ5NjdMpUO-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWS9TrQEnwCqvOzSB1Sf89WqjB6lvEmy9F8vh24AqM-vhbm-c3LO6DoXNNjWCKo9OPDq8nO1ES6r9EJzbxaHPvrlKxv-FMjipbSVcymHNWD3dJTpXeLrH3ZgqLjPA7OYM2U6tFp0NaBOZAUFq3lbNBB68p-7XufjaOFUKGUpbCjKUoS3qbduzlHsqzMB1aQs8uNgc695GGbz_cSwLaL6O3MJ5oObC1ihsRy7YkSIXs6TQpXnrRHIZ1D263bSLCdzNiEIa-ETO7d7bsAiNM9YlUWPac9kgfXAHVeOF8mHmhF4YrKWEx9HQpFw5VaeGWBgOgWgKyB4s99UncfOIOgKL8JfHOkQ9JZplOTdQm-oLuXJIeY7s6d6mG67XFid9UY3iIR7c2wEq9-nbnLAHcqEL4JpcEmqNdxT1H7xIrjqSJbVbFcGU0q_qBl_k

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

Monaco bug example

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.