Skip to content

Prevent ligatures between inlay hints and editor contents (Fix #170449)#182379

Merged
hediet merged 1 commit into
microsoft:mainfrom
r3m0t:fix-170449
May 22, 2023
Merged

Prevent ligatures between inlay hints and editor contents (Fix #170449)#182379
hediet merged 1 commit into
microsoft:mainfrom
r3m0t:fix-170449

Conversation

@r3m0t

@r3m0t r3m0t commented May 13, 2023

Copy link
Copy Markdown
Contributor

Fixes #170449

Setting:

    "editor.fontLigatures": "'liga', 'calt', 'cv16'", // *
"editor.fontFamily": "'Fira Code'",

Extension:

vscode.languages.registerInlayHintsProvider({pattern: "**"}, {
		provideInlayHints(document, range, token) {
			const ret:vscode.InlayHint[] = [];
			for (let i = range.start.line; i <= range.end.line; i++) {
				const lineText = document.lineAt(i).text;
				for (const j of lineText.matchAll(/&/g)) {
					ret.push({label: "&", position: new vscode.Position(i, j.index!)});
				}
				for (const j of lineText.matchAll(/==/g)) {
					ret.push({label: "=", position: new vscode.Position(i, j.index!)});
				}
				if (token.isCancellationRequested) throw new vscode.CancellationError();
			}
			return ret;
		},
	});

Expected result:

image

vs VS Code:

image

See https://www.w3.org/TR/2023/CRD-css-text-3-20230213/#boundary-shaping

@hediet hediet added this to the May 2023 milestone May 22, 2023
@hediet

hediet commented May 22, 2023

Copy link
Copy Markdown
Member

Thanks a lot!

@hediet hediet enabled auto-merge May 22, 2023 09:57
@hediet hediet merged commit 09f80f4 into microsoft:main May 22, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ligatures are formed between inlay hints and code as well as between separate inlay hints

3 participants