microsoft / microsoft/monaco-editor
[Bug] Invalid code action provided when selecting all text
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
// Add additional d.ts files to the JavaScript language service and change.
// Also change the default compilation options.
// The sample below shows how a class Facts is declared and introduced
// to the system and how the compiler is told to use ES6 (target=2).
// validation settings
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
});
// compiler options
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES2015,
lib: ['ES6'],
allowNonTsExtensions: true,
allowJs: true,
});
var jsCode = `const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, 'foo');
});
Promise.all([promise1, promise2, promise3]).then((values) => {
console.log(values);
});
// Expected output: Array [3, 42, "foo"]
`;
monaco.editor.create(document.getElementById("container"), {
value: jsCode,
language: "javascript",
});
Reproduction Steps
Using the code above, if I select the entire content (using Ctrl+A), the lightbulb icon is shown. This suggests a quickfix of removing the variable statement
Actual (Problematic) Behavior
While there is no apparent issue with the code, the quick fix suggests to remove the entire statement, thus leaving the remaining code invalid.
Expected Behavior
The quickfix shouldn't pop up
Additional Context
No response
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 linked Monaco Editor Playground reproduction and run the provided JavaScript sample. Select all text with Ctrl+A, inspect the lightbulb's remove-variable quickfix, and trace why it is offered for the full selection. Done means the quickfix does not appear for this selection while valid code remains unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100