Fix: Correct syntax highlighter match group indices

The regex groups were misaligned:
- match[3] is KeyPath (\.self), not modifier
- match[4] is modifier (.bold), not keyword
- match[5] is keyword, not type
- match[6] is type (was missing)
This commit is contained in:
phranck
2026-02-09 00:09:32 +01:00
parent d7b41f5e6e
commit 0e693145da
+12 -5
View File
@@ -162,25 +162,32 @@ function tokenizeSegment(segment: string) {
</span>
);
} else if (match[3]) {
// Modifier (.bold, .foregroundColor): add dot+name, then the ( back
// KeyPath (\.self)
parts.push(
<span key={match.index} style={{ color: HIGHLIGHT.modifier }}>
{match[3]}
</span>
);
parts.push("(");
} else if (match[4]) {
// Keyword
// Modifier (.bold, .foregroundColor): add dot+name, then the ( back
parts.push(
<span key={match.index} style={{ color: HIGHLIGHT.keyword }}>
<span key={match.index} style={{ color: HIGHLIGHT.modifier }}>
{match[4]}
</span>
);
parts.push("(");
} else if (match[5]) {
// Keyword
parts.push(
<span key={match.index} style={{ color: HIGHLIGHT.keyword }}>
{match[5]}
</span>
);
} else if (match[6]) {
// Type
parts.push(
<span key={match.index} style={{ color: HIGHLIGHT.type }}>
{match[5]}
{match[6]}
</span>
);
}