microsoft / microsoft/monaco-editor
[Bug] inlineEdit.trigger action not working as expected
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 = /* set from `myEditor.getModel()`: */ `// This is some existing text `;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "javascript",
automaticLayout: true,
});
monaco.languages.registerInlineEditProvider("javascript", {
provideInlineEdit: async (model, context, token) => {
console.log("provideInlineEdit called with ", context);
const position = myEditor.getPosition();
return Promise.resolve({
text: "insert text",
range: {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: position.column,
endColumn: position.column,
}
})
},
freeInlineEdit: (args) => {}
});
myEditor.updateOptions({
experimentalInlineEdit: {
enabled: true,
showToolbar: "always"
}
});
myEditor.onDidChangeCursorPosition(() => {
console.log("Cursor position changed: ", myEditor.getPosition());
console.log("Triggering inline edit");
myEditor.trigger("", "editor.action.inlineEdit.trigger", {});
myEditor.trigger("", "editor.action.inlineEdits.trigger", {});
});
Reproduction Steps
Try moving the cursor in the monaco editor (in the playground) and even though the triggers are being called on every cursor change, the provideInlineEdit function does not get called.
I am trying the triggers: "editor.action.InlineEdit.trigger" and "editor.action.InlineEdits.trigger".
Actual (Problematic) Behavior
The triggers: "editor.action.InlineEdit.trigger" and "editor.action.InlineEdits.trigger" are being called on the cursor change event but it is invoking the provideInlineEdit function defined by the provider on every cursor change.
Expected Behavior
The provideInlineEdit function should get triggered every time the triggers: "editor.action.InlineEdit.trigger" and "editor.action.InlineEdits.trigger" are invoked.
Additional Context
I am trying to implement AI inline edits using this functionality but it is not working as expected. I believe that the inline edit feature is still in the experimental stage.
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 run the provided TypeScript reproduction, checking both editor.action.inlineEdit.trigger and editor.action.inlineEdits.trigger. Trace whether either action reaches the registered provideInlineEdit callback; done means the documented trigger invokes that callback reliably on demand and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100