microsoft / microsoft/monaco-editor

[Bug] Update Inlay Hints Provider Example to use `paddingRight` and `paddingLeft`

Open
#4,470 0 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.47.0#XQAAAAJGBgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw_MnGRgmSaumWUF-TBOs7hVNPXc5Iv5vs3RB5mlylvG051-DfnCEgCN-B2M7mD076Fmw32M_5YJEJO_6SDm80o3ulryAn99D8wWHouPLBhxnXI-nTfrfb4M6Tvx1j_vvdMocHG4qGF_LhoF-kfEiDDlKrkbdX7NHwZw4JOUT-pUYc5dZzTI3QyhbZtCI9Wt3nWIGT0jkZIxqBVRM-vBEdnHl9AYl-KGGVBadSExWlgDbknOQ8MUr6NZ4GNyddUiVk6rArLzccBNHZDWuunilebIBnuu6lDsQNlUPmzSlMW-hQun7_ZS3c62WCQDQY4I1niLcF1I95_Onk13HpUlYYfUho-g6ZriRqtA06Sh-DGc8ZXul6UyNFcq3ulzJ8u75QPeoh8dIXdSORgnXJ6DwELj9Sha0ax3u61kn1O1L3PUZXmCSrh3KwZ06BVTYIn-cOTqjXPC5nCMvqWM2YMWwb26Jbegqty730sXqtMkY8XTUWVN8-zX-TldHgyqfuWolTswk1GeLjEIiwD9jsyQPKBlboOg8mhEDsexgIPVbyOYzsBqz_812Blg

Monaco Editor Playground Code
const value = `
const f = (a, b) => a + b;

const result = f(2, 5);
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: 5 },
					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`,
				},
				
				{
					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, // old parameter does not work anymore
				},
				{
					kind: monaco.languages.InlayHintKind.Parameter,
					position: { column: 18, lineNumber: 5 },
					label: `a:`,
				},
				{
					kind: monaco.languages.InlayHintKind.Parameter,
					position: { column: 21, lineNumber: 5 },
					label: `b:`,
					paddingRight: true, // paddingRight works
				},
			],
			dispose: () => {},
		};
	},
});
Reproduction Steps
  1. Load the Inlay Hints Provider Example
  2. Note that the whitespaceBefore and whitespaceAfter properties do not affect the result
  3. Change to paddingLeft and paddingRight and see impact
Actual (Problematic) Behavior
  1. Note that the whitespaceBefore and whitespaceAfter properties do not affect the result
Expected Behavior

Example should use correct properties

image

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 Inlay Hints Provider Example and its Monaco Editor Playground reproduction. Compare the example's whitespaceBefore and whitespaceAfter properties with the documented paddingLeft and paddingRight behavior; it is done when the example uses the correct properties and the playground reproduces the expected padding.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
documentation
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.