microsoft / microsoft/monaco-editor

[Bug] inlineEdit.trigger action not working as expected

Open
#4,874 2 comments 0 reactions 0 assignees View on GitHub

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?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.2#XQAAAALPBAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw7M2LAc4m7jWi3uGQetsfyL9Rw59E2COVxnxnvCRAg0kwCdQb8ogwu-POzKkkdtD5TzWjqVrEVwEMSpGc43m1G4E_3xsiuf3S4-OZgeIvwsKN0nE2W8eOTUl8_QtBLL1Z0xGP3vXvPEHt7hIFgxMCxMGY69x15CB0GVkSHiiihL0y_1YjXmgaT2QNdBJ5zDh0geQXWUCCCqXaa6QinRJckhA8Dz0a7L1Xc9guVk5LLib4E8eDTDpuEE5uXKTOHEIQ0qRcFeWs70AOZAV_VV2aeqPNhLA0bC2taNREup__RQG1viB9ypLGAgU74eEAAQJK4NQkYEYR7XyUvlAMBcEr-pZG0oRQRimXk7mF_wglLYnSkpQGy73LYppYV4oJirgJ8JgIwp28DBN95nOOBlPmac2jbLthpbvp5ekMqDoTR4cY1NXzkPTHQfzpu3-op3bocElIf-3RWxp5Kve7b-vFoGaCzv5GFtoU5Vbkr3KsgfmqYJVvynhTlMdYZrsJYA1hwW53qOTw2SH6OcCjyYwwQE2BFFX7K8rpHRNnxbihTG3zrMb6uZ_6rGkhyRe0kMgPzc0SPPIJkrvL660dTmKJzk0dJ4zNajjI7bwjOupk6FGbhYUaGD1564iMs41U1E4JLH69-yiCvQ_45tK7ciBjThCPYIrDdDWdzbvVJfrC6VC9KYgim25VfSCaAFbtNZR2nnVoTTTXp6ApfYKZd96fwkvoDB17ByAGBF8rxL9FZTnqjiZjJyL30g4Inf7nRtI

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

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.