microsoft / microsoft/monaco-editor

[Bug] Guidelines not rendering in correct positions

Open
#4,695 1 comment 0 reactions 0 assignees View on GitHub

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

No response

Monaco Editor Playground Code

No response

Reproduction Steps
  1. Get the latest source from the repository. The follwing will download the package as a .tgz file into your working directory and extract it:
npm pack monaco-editor
tar xvf monaco-editor-0.52.0.tgz
  1. Paste the code below into an index.html file in the same directory where you downloaded the code to:
<!DOCTYPE html>
<html>
<head>
    <title>Monaco Test</title>
    <link rel="stylesheet" type="text/css" data-name="vs/editor/editor.main" href="package/min/vs/editor/editor.main.css">
    
    <style>
        /* In our codebase this is set globally and cannot be changed */
        * {
            font-family: arial, serif;
            font-size: 14px;
        }

        /* I used this to reset all styles that might colide with editor.main.css. This worked beautifully. */
        .monaco-editor, .monaco-editor *, .monaco-diff-editor, .monaco-diff-editor * {
            all: revert;
        }
    </style>
</head>
<body>
    <div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>

    <script> var require = {"paths": {"vs": window.location.origin + "/monaco-editor-0.52.0/dev/vs"}};</script>
    <script src="package/min/vs/loader.js" language="javascript" type="text/javascript"></script>
    <script src="package/min/vs/editor/editor.main.js" language="javascript" type="text/javascript"></script>

    <script>
        var editor = monaco.editor.create(document.getElementById('container'), {
            value: ['function x() {', '\tconsole.log("Hello world!");', '\t{', '\t\tconsole.log("Indentedline");', '\t}', '}'].join('\n'),
            language: 'javascript',
        });
    </script>
</body>
</html>
  1. Open the index.html file using VSCode LiveServer.
  2. Then the problem should already be appearent.
Actual (Problematic) Behavior

The guideline is drawn in the wrong spot:
image

Expected Behavior

The guideline should be drawn like this:
image

Additional Context

No response

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 supplied index.html reproduction, especially package/min/vs/editor/editor.main.css and package/min/vs/editor/editor.main.js, and compare the guideline position with and without the global font rules and all: revert reset. Reproduce it through VSCode LiveServer, then trace how those styles affect guideline placement; done means the guideline matches the expected position without breaking the reset scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.