microsoft / microsoft/monaco-editor

[Bug] `lightbulb` for `CodeAction` Not Showing When Text Has Only One Line

Open
#4,710 0 comments 0 reactions 1 assignee View on GitHub

@justschen is already working on this.

Since Oct 29, 2024.

bug
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.52.0#XQAAAAJwBQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw9CjY_bpo6KbyT6d2s9ZojPnuzKxfrOqkaStQzt0QE8ylcxrmJHlBybvf-kBdud0AQXOvLHWt-zimOi9mZPBytDTLTgLhwNh4i4bdLlQZxotcJpJkLg9a0QruluPmik4k-3NdfQw4QqFKBRqW9hP27oFXeHLJd0XSjVKAI34YFiRBaLzLMljC9NI5Mo_aDHPNC9eqggEOlRZrIFLGNWlbaR3NUqow8IzBTbT4pIVyC6JufdglehcRmQSEapSV7S_962dw_IpUE7sbCqQwVO96omhiWR0_DJN7zI5MQnjm09fqA1F3AE6GJNIMAMkciQhlh7TamTK0mfXgH5AFEUk4jlzRFNG7vejwlvxRs-rdRQehe1SR1CXPO-4sJo7MS0K-JamqVytSGBtUHIMzzx1VSFmmCa64IpKUZjzV7uLcIiDaYULxuSXKmh4NcIAkdF-q42a3XZuaPRzSUR4Ul_SZN7j41UG-oLE4lWkt1T2DBMcNVZLqW8x8PkK0iYcOaqsLs0X08oIs01ArGvuLmQ8Mt-lWGzqg_N-51zybcu0K-uW3b3DkTJR8gHAXSFpGgvyk7S5IXWGgaW3uq9XFMhs5zgXYOWSjMi36wLz4Rtjn1iTTMjREsLQlzvYvl4vyHWNtRMP8PzcFQ55L1jJe8lc6jTg6fmUOOkK4BjwdxwnJFVaFUYXYNyloGkYKBkjCSFw7U7IXQNNYDfL-XLAm7-zrpHoVg932rZ_T5KQzKZdIIz7QTOXoLzREP5IOCUvRC8E0OZOeHIYngAHAL9IsNY4vF_odVw7APFxkDWm-jbKzuT4REYLWgVq2t8G7XoyF7vmIsIAInNLSOzKtLMA9eK-gJVAi1QQXOt__8mKBCQ

Monaco Editor Playground Code
monaco.languages.register({id: "rule"})

monaco.languages.registerCodeActionProvider("rule", {
    provideCodeActions: (model, range, context, token) => {
		console.log("test");
        return {
            actions: [{
                title: "Test",
                ranges: [new monaco.Range(0, 0, 1, 1)],
                command: {
                    id: "test",
                    arguments: []
                }
            }],
            dispose: () => {}
        }
    },
    resolveCodeAction: () => {
        return null;
    }
});

const model = monaco.editor.createModel("just for test", "rule", monaco.Uri.parse("inmemory://test"));

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
    model,
    theme: "vs-dark",
    autoClosingQuotes: "always",
    autoClosingBrackets: "always",
    "semanticHighlighting.enabled": true,
    wordWrap: 'on',
    lineNumbersMinChars: 2,
    overviewRulerLanes: 0,
    overviewRulerBorder: false,
    hideCursorInOverviewRuler: true,
    glyphMargin: false,
    folding: false,
    scrollBeyondLastColumn: 0,
    scrollBeyondLastLine: false,
    quickSuggestionsDelay: 100,
    scrollbar: { horizontal: 'hidden', vertical: 'hidden', alwaysConsumeMouseWheel: false },
    minimap: { enabled: false },
});

Reproduction Steps

When clicking on the text to trigger the lightbulb, we notice that the lightbulb does not appear.

Actual (Problematic) Behavior
  1. When there is only one line of text, the lightbulb icon does not appear.
    Image

  2. When there are empty lines before and after the input text, the lightbulb icon displays correctly.
    Image

Expected Behavior

When there is no suitable position to display the lightbulb, it should be shown on the current line.

Additional Context

Maybe relative:

https://github.com/microsoft/vscode/issues/225459
https://github.com/microsoft/vscode/issues/213657
https://github.com/microsoft/vscode/pull/227138

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.