git-tweezers
Version:
Advanced git staging tool with hunk and line-level control
32 lines (31 loc) • 1.27 kB
TypeScript
import type { ExtendedLineChange } from '../types/extended-diff.js';
import type { ParsedHunk } from './diff-parser.js';
export interface LineMapping {
lineNumber: number;
change?: ExtendedLineChange;
isContextLine: boolean;
}
/**
* Maps line numbers in the NEW file to their corresponding changes in the diff
* Uses the algorithm suggested by o3: track both old and new line counters
*/
export declare class LineMapper {
/**
* Create a map from new file line numbers to changes
*/
static mapNewLinesToChanges(hunk: ParsedHunk): Map<number, ExtendedLineChange>;
/**
* Check if a change needs its EOF newline pair
* This happens when adding a line after a line that has no newline
*/
static needsEOFPair(change: ExtendedLineChange, index: number, allChanges: ExtendedLineChange[]): boolean;
/**
* Find the corresponding change that adds newline to a no-EOL line
*/
static findEOLFixChange(noEOLChange: ExtendedLineChange, hunk: ParsedHunk): ExtendedLineChange | null;
/**
* Get all changes needed for staging specific lines
* This includes handling EOF newline dependencies
*/
static getRequiredChanges(hunk: ParsedHunk, targetLines: Set<number>): ExtendedLineChange[];
}