Syntax-highlight Edit, Write, and Read tool calls (#1218)
Highlighting reuses the existing code-block tokenizer and LRU cache, runs lazily on expand, and falls back to plain text above a size cap so a large Read can't stall the main thread. The diff highlighter reconstructs the old and new file text by position rather than from @@ line ranges, so diffs that arrive without real hunk headers still highlight. Read content is normalized server-side: the cat -n line-number gutter some providers emit is stripped so content is uniformly raw source, with the first line number surfaced as offset for the client to rebuild the gutter.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import type { HighlightToken } from "@getpaseo/highlight";
|
||||
|
||||
export interface DiffSegment {
|
||||
text: string;
|
||||
@@ -9,6 +10,9 @@ export interface DiffLine {
|
||||
type: "add" | "remove" | "context" | "header";
|
||||
content: string;
|
||||
segments?: DiffSegment[];
|
||||
// Syntax-highlight tokens for the code on this line (prefix char excluded),
|
||||
// attached by highlightDiffLines when the file's language is supported.
|
||||
tokens?: HighlightToken[];
|
||||
}
|
||||
|
||||
function splitIntoLines(text: string): string[] {
|
||||
|
||||
Reference in New Issue
Block a user