mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
702c87853b
* feat(review): token-level code selection for annotations Add the ability to click individual syntax tokens in the diff viewer to create annotations with precise code context. Uses Pierre v1.1.12's onTokenClick/onTokenEnter/onTokenLeave callbacks. - Click a token → toolbar opens with token text in header - Click same token again → deselects - Gutter line selection still works independently - Token metadata (charStart, charEnd, tokenText) stored on CodeAnnotation - Sidebar shows token badge, export includes token context For provenance purposes, this commit was AI assisted. * fix(review): token draft roundtrip, export precision, truncation alignment - Persist tokenSelection in drafts so token context survives file switches - Include char offsets in exported feedback for duplicate token disambiguation - Escape backticks in token text to prevent broken markdown fences - Align sidebar token truncation to 30 chars (matching toolbar header) For provenance purposes, this commit was AI assisted.
18 lines
659 B
TypeScript
18 lines
659 B
TypeScript
/** Formats a line range as "Line 5" (single) or "Lines 5-12" (multi-line) */
|
|
export function formatLineRange(start: number, end: number): string {
|
|
const lo = Math.min(start, end);
|
|
const hi = Math.max(start, end);
|
|
return lo === hi ? `Line ${lo}` : `Lines ${lo}-${hi}`;
|
|
}
|
|
|
|
/** Formats a token selection as "Line 5: `token`" */
|
|
export function formatTokenContext(tokenSelection: {
|
|
anchor: { lineNumber: number };
|
|
fullText: string;
|
|
}): string {
|
|
const display = tokenSelection.fullText.length > 30
|
|
? tokenSelection.fullText.slice(0, 27) + '...'
|
|
: tokenSelection.fullText;
|
|
return `Line ${tokenSelection.anchor.lineNumber}: \`${display}\``;
|
|
}
|