monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Bug] Invalid code action provided when selecting all text

Open parthverma1 opened this issue 2 years ago • 1 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] 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.44.0#XQAAAAI1BAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw5c1BeH9Lk6dVRoGmlOsCWG55Tgtd-zhH9YwpoMsaCfCS71ss8FFzmIcOqARoRAb6HRMoOcO786l8L5tdMWyELs2N70bS103gid3b3_0bnQLLkmrpmGu_EhWoCLAoYpMsKJ1_sF2QrE9LqFkcPYhAh20p3TLvT4dhIRnmTi-AZrMNlKfuxVcXl_aBBSoYGzPR9YE6ils5aNRtorDgUxS5WUMSIfaTlEiKa2KOPZjns9VjM_HbKci7PUEvUQaUGNhscJcRV-e91TlgSptyeuVQWVE_i-5hhLLUAozbqjZaodtEq1No6jEnGBOawY1JacLPYFZ-P66DiTKF3LLwUMNUsevNQcJa7yjWZ16ayofkN4ME4lqW8oEdZebTKMLpgcnvB2zOqHPe8ulYmf6C8pU1mJKjRkK8bCAzBuE6ghcK7FOd8ChhnEhG2wzEudHqHC89Vu2OQGZIgwCBUo2mYT5D7iXvCjLqlekduysfmkyz3Ljg13uTvU2okQTV-ikDQwXKQFVDlGJrGrOzuDblPJJm5Ehiur4ECenz6QlTrf6E4LrvsF6_yTQy5aEmxVpC9zK0tUlSB-jfva9XfdUIGwxif_lPiwJ9mbdQ-bpvTFmyCkZFTrf5XuNs3MWbB3LUiSaF5OubSG1zQkwTmzHcJOqQb_5keqJetBD19jmstj6I5L2c5Lkh4ULoStuAGnWV__pnSf3s0EX7mDfzhnc9LmbZRb8-JAl5meYxegJZjy94lPcvUb_5Ck0Cg

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 image

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

parthverma1 avatar Nov 16 '23 19:11 parthverma1

I believe this is fixed in newer versions of typescript.

hediet avatar Dec 14 '23 10:12 hediet