diff --git a/extensions/studio/src/browser/comment-font-decorator.ts b/extensions/studio/src/browser/comment-font-decorator.ts index bdcd3c0..e6a74a7 100644 --- a/extensions/studio/src/browser/comment-font-decorator.ts +++ b/extensions/studio/src/browser/comment-font-decorator.ts @@ -49,7 +49,7 @@ export class CommentFontDecorator implements FrontendApplicationContribution { async onStart(): Promise { await this.preferenceService.ready; const current = this.preferenceService.get("editor.fontFamily"); - if (!current || current === "monospace") { + if (!current || !current.includes("Monaspace")) { this.preferenceService.set( "editor.fontFamily", "'Monaspace Neon', monospace", @@ -110,36 +110,36 @@ export class CommentFontDecorator implements FrontendApplicationContribution { const lineTokens = tokenization.getLineTokens(lineNumber); const lineContent = model.getLineContent(lineNumber); - let lineIsComment = false; for (let i = 0; i < lineTokens.getCount(); i++) { - if (lineTokens.getStandardTokenType(i) === COMMENT_TOKEN_TYPE) { - lineIsComment = true; - break; + if (lineTokens.getStandardTokenType(i) !== COMMENT_TOKEN_TYPE) { + continue; } - } - if (!lineIsComment) { - continue; + const startOffset = lineTokens.getStartOffset(i); + const endOffset = + i + 1 < lineTokens.getCount() + ? lineTokens.getStartOffset(i + 1) + : lineContent.length; + + const tokenText = lineContent.substring(startOffset).trimStart(); + const isDocComment = tokenText.startsWith("///"); + const className = isDocComment + ? "comment-font-xenon" + : "comment-font-radon"; + + newDecorations.push({ + range: { + startLineNumber: lineNumber, + startColumn: startOffset + 1, + endLineNumber: lineNumber, + endColumn: endOffset + 1, + }, + options: { + description: className, + inlineClassName: className, + }, + }); } - - const trimmed = lineContent.trimStart(); - const isDocComment = trimmed.startsWith("///"); - const className = isDocComment - ? "comment-font-xenon" - : "comment-font-radon"; - - newDecorations.push({ - range: { - startLineNumber: lineNumber, - startColumn: 1, - endLineNumber: lineNumber, - endColumn: lineContent.length + 1, - }, - options: { - description: className, - inlineClassName: className, - }, - }); } decorations.set(newDecorations as any);