diff --git a/src/vs/editor/contrib/inlayHints/inlayHintsController.ts b/src/vs/editor/contrib/inlayHints/inlayHintsController.ts index 6e6350d6ffc..e6b191ccfbd 100644 --- a/src/vs/editor/contrib/inlayHints/inlayHintsController.ts +++ b/src/vs/editor/contrib/inlayHints/inlayHintsController.ts @@ -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 => {