microsoft / microsoft/monaco-editor
[Bug] CodeActionProvider text edits doesn't work correctly with flag insertAsSnippet
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
const value = `
const f = (a, b) => a + b;
const result = f(2, 5);
`;
const editor = monaco.editor.create(document.getElementById("container"), {
value,
language: "javascript",
});
monaco.languages.registerCodeActionProvider("javascript", {
provideCodeActions: (model, range, context) => {
return {
actions: [
{
title: "Test action",
edit: {
edits: [
{
resource: model.uri,
textEdit: {
range: {startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1},
text: "const ${1:test};",
insertAsSnippet: true,
},
versionId: undefined,
}
]
}
}
],
dispose: () => {}
}
}
});
Reproduction Steps
try to use code action
Actual (Problematic) Behavior
code action insert text marked as snipped without modifying
Expected Behavior
code action insert text marked as snipped similar to CompletionProvider snippets
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 and the provided CodeActionProvider reproduction. Compare the code-action text edit behavior with the expected CompletionProvider snippet behavior, then locate the relevant editor API implementation and tests; no specific files or tests are named in the issue. Done means applying the action inserts and activates the ${1:test} snippet rather than plain text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100