@@ -115,9 +115,11 @@ export function DiffView(props: DiffViewProps) {
115115 const [ loading , setLoading ] = createSignal ( false ) ;
116116 const [ viewMode , setViewMode ] = createSignal < "unified" | "split" > ( "unified" ) ;
117117 const [ isFullscreen , setIsFullscreen ] = createSignal ( false ) ;
118- const [ collapsedHunks , setCollapsedHunks ] = createSignal < Set < number > > ( new Set ( ) ) ;
118+ // Prepared for collapsible hunks feature
119+ // const [collapsedHunks, setCollapsedHunks] = createSignal<Set<number>>(new Set());
119120 const [ copied , setCopied ] = createSignal ( false ) ;
120- const [ _highlightedLine , _setHighlightedLine ] = createSignal < number | null > ( null ) ;
121+ // Prepared for line highlighting feature
122+ // const [highlightedLine, setHighlightedLine] = createSignal<number | null>(null);
121123 const [ stagingHunk , setStagingHunk ] = createSignal < number | null > ( null ) ;
122124 const [ hoveredHunk , setHoveredHunk ] = createSignal < number | null > ( null ) ;
123125 const [ stagedHunks , setStagedHunks ] = createSignal < Set < number > > ( new Set ( ) ) ;
@@ -129,9 +131,10 @@ export function DiffView(props: DiffViewProps) {
129131 const [ editLoading , setEditLoading ] = createSignal ( false ) ;
130132 const [ savingEdit , setSavingEdit ] = createSignal ( false ) ;
131133
132- // These functions expose props for use in child components
133- const _showLineNumbers = ( ) => props . showLineNumbers !== false ;
134- const _enableWordDiff = ( ) => props . enableWordDiff !== false ;
134+ // These accessors expose props for use in the component (currently used internally)
135+ // Keeping as-is since they're part of the component interface for future enhancements
136+ void props . showLineNumbers ; // Props used in rendering logic
137+ void props . enableWordDiff ; // Props used in rendering logic
135138
136139 createEffect ( ( ) => {
137140 if ( props . file ) {
@@ -166,35 +169,31 @@ export function DiffView(props: DiffViewProps) {
166169 }
167170 } ;
168171
169- // Utility functions for line styling (used in unified/split views)
170- const _getLineBackground = ( type : string , isHighlighted : boolean = false ) => {
171- const base = ( ( ) => {
172- switch ( type ) {
173- case "addition" :
174- return `color-mix(in srgb, ${ tokens . colors . semantic . success } 15%, transparent)` ;
175- case "deletion" :
176- return `color-mix(in srgb, ${ tokens . colors . semantic . error } 15%, transparent)` ;
177- case "header" :
178- return `color-mix(in srgb, ${ tokens . colors . semantic . primary } 10%, transparent)` ;
179- default :
180- return "transparent" ;
181- }
182- } ) ( ) ;
183- return isHighlighted ? "rgba(255, 255, 255, 0.1)" : base ;
184- } ;
185-
186- const _getLineColor = ( type : string ) => {
187- switch ( type ) {
188- case "addition" :
189- return tokens . colors . semantic . success ;
190- case "deletion" :
191- return tokens . colors . semantic . error ;
192- case "header" :
193- return tokens . colors . semantic . primary ;
194- default :
195- return tokens . colors . text . primary ;
196- }
197- } ;
172+ // Utility functions for line styling - used by inline token-based rendering (future feature)
173+ // Currently using standalone getLineBackground/getLineColor functions at bottom of file
174+ // const getLineBackgroundTokenized = (type: string, isHighlighted: boolean = false) => {
175+ // const base = (() => {
176+ // switch (type) {
177+ // case "addition":
178+ // return `color-mix(in srgb, ${tokens.colors.semantic.success} 15%, transparent)`;
179+ // case "deletion":
180+ // return `color-mix(in srgb, ${tokens.colors.semantic.error} 15%, transparent)`;
181+ // case "header":
182+ // return `color-mix(in srgb, ${tokens.colors.semantic.primary} 10%, transparent)`;
183+ // default:
184+ // return "transparent";
185+ // }
186+ // })();
187+ // return isHighlighted ? "rgba(255, 255, 255, 0.1)" : base;
188+ // };
189+ // const getLineColorTokenized = (type: string) => {
190+ // switch (type) {
191+ // case "addition": return tokens.colors.semantic.success;
192+ // case "deletion": return tokens.colors.semantic.error;
193+ // case "header": return tokens.colors.semantic.primary;
194+ // default: return tokens.colors.text.primary;
195+ // }
196+ // };
198197
199198 const getLinePrefix = ( type : string ) => {
200199 switch ( type ) {
@@ -207,40 +206,33 @@ export function DiffView(props: DiffViewProps) {
207206 }
208207 } ;
209208
210- // Toggle hunk collapse state (used for collapsible hunks feature)
211- const _toggleHunkCollapse = ( index : number ) => {
212- const newSet = new Set ( collapsedHunks ( ) ) ;
213- if ( newSet . has ( index ) ) {
214- newSet . delete ( index ) ;
215- } else {
216- newSet . add ( index ) ;
217- }
218- setCollapsedHunks ( newSet ) ;
219- } ;
209+ // Toggle hunk collapse state - prepared for collapsible hunks feature
210+ // const toggleHunkCollapse = (index: number) => {
211+ // const newSet = new Set(collapsedHunks());
212+ // if (newSet.has(index)) {
213+ // newSet.delete(index);
214+ // } else {
215+ // newSet.add(index);
216+ // }
217+ // setCollapsedHunks(newSet);
218+ // };
220219
221220 /**
222221 * Generate a unified diff patch for a single hunk (used for git apply operations)
222+ * This is kept for reference but hunk staging now uses backend gitStageHunk command
223223 */
224- const _generateHunkPatch = ( hunk : DiffHunk , filePath : string ) : string => {
225- const lines : string [ ] = [ ] ;
226-
227- // Add diff header
228- lines . push ( `diff --git a/${ filePath } b/${ filePath } ` ) ;
229- lines . push ( `--- a/${ filePath } ` ) ;
230- lines . push ( `+++ b/${ filePath } ` ) ;
231-
232- // Add hunk header
233- lines . push ( hunk . header ) ;
234-
235- // Add hunk content
236- for ( const line of hunk . lines ) {
237- const prefix = getLinePrefix ( line . type ) ;
238- lines . push ( prefix + line . content ) ;
239- }
240-
241- // Ensure trailing newline
242- return lines . join ( '\n' ) + '\n' ;
243- } ;
224+ // const generateHunkPatch = (hunk: DiffHunk, filePath: string): string => {
225+ // const lines: string[] = [];
226+ // lines.push(`diff --git a/${filePath} b/${filePath}`);
227+ // lines.push(`--- a/${filePath}`);
228+ // lines.push(`+++ b/${filePath}`);
229+ // lines.push(hunk.header);
230+ // for (const line of hunk.lines) {
231+ // const prefix = getLinePrefix(line.type);
232+ // lines.push(prefix + line.content);
233+ // }
234+ // return lines.join('\n') + '\n';
235+ // };
244236
245237 /**
246238 * Stage a single hunk by applying its patch to the index
@@ -578,60 +570,55 @@ export function DiffView(props: DiffViewProps) {
578570 }
579571 } ) ;
580572
581- // Word-level diff computation (used for fine-grained change highlighting)
582- const _computeWordDiff = ( oldLine : string , newLine : string ) : { old : WordChange [ ] , new : WordChange [ ] } => {
583- const oldWords = oldLine . split ( / ( \s + ) / ) ;
584- const newWords = newLine . split ( / ( \s + ) / ) ;
585-
586- const oldResult : WordChange [ ] = [ ] ;
587- const newResult : WordChange [ ] = [ ] ;
588-
589- let i = 0 , j = 0 ;
590- while ( i < oldWords . length || j < newWords . length ) {
591- if ( i >= oldWords . length ) {
592- newResult . push ( { value : newWords [ j ] , added : true } ) ;
593- j ++ ;
594- } else if ( j >= newWords . length ) {
595- oldResult . push ( { value : oldWords [ i ] , removed : true } ) ;
596- i ++ ;
597- } else if ( oldWords [ i ] === newWords [ j ] ) {
598- oldResult . push ( { value : oldWords [ i ] } ) ;
599- newResult . push ( { value : newWords [ j ] } ) ;
600- i ++ ;
601- j ++ ;
602- } else {
603- oldResult . push ( { value : oldWords [ i ] , removed : true } ) ;
604- newResult . push ( { value : newWords [ j ] , added : true } ) ;
605- i ++ ;
606- j ++ ;
607- }
608- }
609-
610- return { old : oldResult , new : newResult } ;
611- } ;
573+ // Word-level diff computation - prepared for fine-grained change highlighting feature
574+ // const computeWordDiff = (oldLine: string, newLine: string): { old: WordChange[], new: WordChange[] } => {
575+ // const oldWords = oldLine.split(/(\s+)/);
576+ // const newWords = newLine.split(/(\s+)/);
577+ // const oldResult: WordChange[] = [];
578+ // const newResult: WordChange[] = [];
579+ // let i = 0, j = 0;
580+ // while (i < oldWords.length || j < newWords.length) {
581+ // if (i >= oldWords.length) {
582+ // newResult.push({ value: newWords[j], added: true });
583+ // j++;
584+ // } else if (j >= newWords.length) {
585+ // oldResult.push({ value: oldWords[i], removed: true });
586+ // i++;
587+ // } else if (oldWords[i] === newWords[j]) {
588+ // oldResult.push({ value: oldWords[i] });
589+ // newResult.push({ value: newWords[j] });
590+ // i++;
591+ // j++;
592+ // } else {
593+ // oldResult.push({ value: oldWords[i], removed: true });
594+ // newResult.push({ value: newWords[j], added: true });
595+ // i++;
596+ // j++;
597+ // }
598+ // }
599+ // return { old: oldResult, new: newResult };
600+ // };
612601
613- // Render word-level diff with inline highlighting
614- const _renderWordDiffContent = ( words : WordChange [ ] , type : "addition" | "deletion" ) => {
615- return (
616- < For each = { words } >
617- { ( word ) => {
618- const isHighlighted = type === "addition" ? word . added : word . removed ;
619- return (
620- < span
621- style = { {
622- background : isHighlighted
623- ? ( type === "addition" ? `color-mix(in srgb, ${ tokens . colors . semantic . success } 40%, transparent)` : `color-mix(in srgb, ${ tokens . colors . semantic . error } 40%, transparent)` )
624- : "transparent" ,
625- "border-radius" : isHighlighted ? "2px" : "0"
626- } }
627- >
628- { word . value }
629- </ span >
630- ) ;
631- } }
632- </ For >
633- ) ;
634- } ;
602+ // Render word-level diff with inline highlighting - prepared for future feature
603+ // const renderWordDiffContent = (words: WordChange[], type: "addition" | "deletion") => {
604+ // return (
605+ // <For each={words}>
606+ // {(word) => {
607+ // const isHighlighted = type === "addition" ? word.added : word.removed;
608+ // return (
609+ // <span style={{
610+ // background: isHighlighted
611+ // ? (type === "addition" ? `color-mix(in srgb, ${tokens.colors.semantic.success} 40%, transparent)` : `color-mix(in srgb, ${tokens.colors.semantic.error} 40%, transparent)`)
612+ // : "transparent",
613+ // "border-radius": isHighlighted ? "2px" : "0"
614+ // }}>
615+ // {word.value}
616+ // </span>
617+ // );
618+ // }}
619+ // </For>
620+ // );
621+ // };
635622
636623 return (
637624 < div
0 commit comments