Merge pull request #129237 from microsoft/hediet/no-break-ws-for-inlay-text

Replaces whitespaces/tab with no-break whitespace for inlay hints.
This commit is contained in:
Henning Dieterichs 2021-07-27 09:48:32 +02:00 committed by GitHub
commit f93aba91e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -157,8 +157,10 @@ export class InlayHintsController implements IEditorContribution {
const marginBefore = whitespaceBefore ? (fontSize / 3) | 0 : 0;
const marginAfter = whitespaceAfter ? (fontSize / 3) | 0 : 0;
const massagedText = fixSpace(text);
const before: IContentDecorationRenderOptions = {
contentText: text,
contentText: massagedText,
backgroundColor: `${backgroundColor}`,
color: `${fontColor}`,
margin: `0px ${marginAfter}px 0px ${marginBefore}px`,
@ -207,6 +209,11 @@ export class InlayHintsController implements IEditorContribution {
}
}
function fixSpace(str: string): string {
const noBreakWhitespace = '\xa0';
return str.replace(/[ \t]/g, noBreakWhitespace);
}
registerEditorContribution(InlayHintsController.ID, InlayHintsController);
CommandsRegistry.registerCommand('_executeInlayHintProvider', async (accessor, ...args: [URI, IRange]): Promise<InlayHint[]> => {