microsoft / microsoft/monaco-editor

[Bug] Decorations cannot appear after inline completions

Open
#4,147 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

editor-core feature-request
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.41.0#XQAAAAITAwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw23CAaAEiAI2noA0ZIx1yl-tBpXaaHrtjz_aQNHMi1VW1WL6AmZwUI5WjXxJSg9eUHcQ72PxYdN3-ekwIJ6Js6TD5RjHpQSXsXYkYn30K6D_l2kbnVOiwGhnG6UMTgi3FecbY79jvb6OBgwAWDAWVlU-7bIIYVBXjm0AQD71kO3gMP3HFyGIpeA5ZkOv-r63rLs05xyazNinJ1fPYzyY3MlygftjxCu22fGUglF6G1BwwUXql6FWOUf2L9U5qEAQI-wtzlVSyD1zaN7D_-fmeInMnnoRsknWjySMM_UItiSoa-p3vE2nC_WY6eiEKg7dYOkvMsjno-kLy0Vd6A9iDcH7VTCyXmW5cR3TsP-t7B09_glnijLuo3XYFKzw1tP6ijSrSotV9aZQkWH4Qw_w-Vxsx-uJSYCGuUYOREespo3WYBLba2YgRcnn7__jP3i9rn10GOMc_OU32rC72Q1-53UJftEC7r1BW2RdDDJF2dkFsN5TvIi-qUDthEdlhK1G49FJKM_ELbW-uRi1Lbaepn71YnvztHYF2Hy9ZYC0m3Z-7rThYypew3__pRMge

Monaco Editor Playground Code
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value: '{\n\t"dependencies": {\n\t\t\n\t}\n}\n',
	language: "json",
});

monaco.languages.registerInlineCompletionsProvider("json", {
	provideInlineCompletions: function (model, position, context, token) {
		return {items: [{insertText: 'foo'}]};
	},
	freeInlineCompletions: function (completions) {
	},
	handleItemDidShow: function (completions, item, updatedInsertText) {
		console.log("Item shown: ", item);
		let range = {'startColumn': 0, 'endColumn': 100, 'startLineNumber': 3, 'endLineNumber': 3};
		let decoration = {'range': range, 'options': {'after': {'content': 'bar'}}};
		myEditor.deltaDecorations([], [decoration]);
	}
	});
Reproduction Steps
  1. Go to line 3
  2. Hit space to trigger an inline completion
  3. The inline completion "foo" and the decoration "bar" both appear
Actual (Problematic) Behavior

The decoration "bar" appears before the inline suggestion "foo" despite the decoration having an endColumn of 100

Expected Behavior

I expect the decoration to appear after the inline suggestion

Additional Context

No response

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 its inline completions provider, reproducing the interaction between the inline suggestion and the after decoration. Trace how inline completions and decorations are positioned together; done means the decoration appears after the inline suggestion in the supplied reproduction without regressing normal decoration placement.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.