mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-13 23:01:09 -07:00
Fix syntax highlighting and rendering issues. (#7759)
Co-authored-by: Miguel Solorio <miguelsolorio@google.com>
This commit is contained in:
@@ -9,10 +9,11 @@ export type HighlightToken = {
|
||||
type: 'default' | 'command' | 'file';
|
||||
};
|
||||
|
||||
const HIGHLIGHT_REGEX = /(\/[a-zA-Z0-9_-]+|@[a-zA-Z0-9_./-]+)/g;
|
||||
const HIGHLIGHT_REGEX = /(^\/[a-zA-Z0-9_-]+|@(?:\\ |[a-zA-Z0-9_./-])+)/g;
|
||||
|
||||
export function parseInputForHighlighting(
|
||||
text: string,
|
||||
index: number,
|
||||
): readonly HighlightToken[] {
|
||||
if (!text) {
|
||||
return [{ text: '', type: 'default' }];
|
||||
@@ -36,10 +37,18 @@ export function parseInputForHighlighting(
|
||||
|
||||
// Add the matched token
|
||||
const type = fullMatch.startsWith('/') ? 'command' : 'file';
|
||||
tokens.push({
|
||||
text: fullMatch,
|
||||
type,
|
||||
});
|
||||
// Only highlight slash commands if the index is 0.
|
||||
if (type === 'command' && index !== 0) {
|
||||
tokens.push({
|
||||
text: fullMatch,
|
||||
type: 'default',
|
||||
});
|
||||
} else {
|
||||
tokens.push({
|
||||
text: fullMatch,
|
||||
type,
|
||||
});
|
||||
}
|
||||
|
||||
lastIndex = matchIndex + fullMatch.length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user