Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Inlay hints duplicate when editor value is updated #4700

Open
1 of 2 tasks
0xMMA opened this issue Oct 1, 2024 · 1 comment
Open
1 of 2 tasks

[Bug] Inlay hints duplicate when editor value is updated #4700

0xMMA opened this issue Oct 1, 2024 · 1 comment

Comments

@0xMMA
Copy link

0xMMA commented Oct 1, 2024

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.33.0#XQAAAAL4BAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw7ec0Eu-n-5ctzOK0Uo_7UZeSGEZyXuNcTAKKg0H9aCn_vMhLAdVZkZjBxVYmeblT2gHUWXqt5sXwcsjO-RGfHkUuWa0xD7enHCr9lsyIaczHt2VbTvJx3eBQnBGJUtudz7PJAnw4TDkA5Gl8-Hbp7UViKGDc5NJPzAghMaO61XTxS8eBugqSUakUN4H56vWynf1IZk5kYUCKYVRDruLHCXv8_sw43lle2e5PpCYaA8pOD-Or6PuFyyAupawRCOq6R4lovZijHSNhDDZeN2hMO-wD0rQbmqwY7JqdyUA1WKzmO1SSJm1BIfKpVTr3-EdkKeMh3laEC_pFuhKrll45vW8se-4BsQXododSN039TCS2OrAyL_vPRdf8ENWroXYNXwyrN3FC8DHYLfS6zoM9LiKilR2WW8OMYkagWaLsr1H2_CZGdxUkaaBpuGXfZ_ggpa60YlIBaxHP7wqeOSZmknBSK2ItWBfwJzI0hJEtuCUpBVx5hfqqFmpYHCOVWEskOThqoNJ05aF3Zpx9s4hA2-uTn_W53N9r2ru8AzGi79RtcVqky9jl3LJedTOCr-wnpalwN8dSJbrMQrYZWfDgtXC__jQkhw

seems to be broken from 0.33 onwards

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.registerInlayHintsProvider("javascript", {
	provideInlayHints(model, range, token) {
		return {
			hints: [
				{
					kind: monaco.languages.InlayHintKind.Type,
					position: { column: 13, lineNumber: 4 },
					label: `: Number`,
				},
				{
					kind: monaco.languages.InlayHintKind.Type,
					position: { column: 13, lineNumber: 2 },
					label: `: Number`,
				},
				{
					kind: monaco.languages.InlayHintKind.Type,
					position: { column: 16, lineNumber: 2 },
					label: `: Number`,
					whitespaceBefore: true, // see difference between a and b parameter
				},
				{
					kind: monaco.languages.InlayHintKind.Parameter,
					position: { column: 18, lineNumber: 4 },
					label: `a:`,
				},
				{
					kind: monaco.languages.InlayHintKind.Parameter,
					position: { column: 21, lineNumber: 4 },
					label: `b:`,
					whitespaceAfter: true, // similar to whitespaceBefore
				},
			],
			dispose: () => {},
		};
	},
});

setTimeout(() => {
editor.setValue(value + " test235");
}, 2000);

Reproduction Steps

  1. load the modified sample
  2. in "preview", click into line 2, right behind parameter "(a:"
  3. you should see that the hints are now duplicated

addition:
if you increaste the amount of "editor.setValue" call the amount of hint duplication stacks accordingly

Actual (Problematic) Behavior

duplicte hints are shown, after the editor value has been set to a new value

image

Expected Behavior

hints are rendered only once, even if editor value is updated

{28735216-227C-47DB-AB99-9F4C9FD251BF}

Additional Context

No response

@0xMMA
Copy link
Author

0xMMA commented Oct 2, 2024

Found this #4658 maybe related

@0xMMA 0xMMA changed the title [Bug] InlayHints duplicate when editor value is updated [Bug] Inlay hints duplicate when editor value is updated Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant