feat: add Apply Patch tool with patch input and diff view (#196)
* feat: add Apply Patch tool with patch input and diff view Introduce Apply Patch tool with a patch input field and diff preview Display target file path or file count for patch operations in tool UI Update status label to show applying patch during execution * fix: include apply_patch in editing tools detection
This commit is contained in:
committed by
GitHub
parent
ef4d37df09
commit
87175566b9
@@ -410,19 +410,22 @@ export const parseDiffToUnified = (diffText: string): UnifiedDiffHunk[] => {
|
||||
const newStart = match ? parseInt(match[2]) : 0;
|
||||
|
||||
const unifiedLines: UnifiedDiffLine[] = [];
|
||||
let lineNum = newStart;
|
||||
let oldLineNum = oldStart;
|
||||
let newLineNum = newStart;
|
||||
let j = i + 1;
|
||||
|
||||
while (j < lines.length && !lines[j].startsWith('@@') && !lines[j].startsWith('Index:')) {
|
||||
const contentLine = lines[j];
|
||||
if (contentLine.startsWith('+')) {
|
||||
unifiedLines.push({ type: 'added', lineNumber: lineNum, content: contentLine.substring(1) });
|
||||
lineNum++;
|
||||
unifiedLines.push({ type: 'added', lineNumber: newLineNum, content: contentLine.substring(1) });
|
||||
newLineNum++;
|
||||
} else if (contentLine.startsWith('-')) {
|
||||
unifiedLines.push({ type: 'removed', lineNumber: null, content: contentLine.substring(1) });
|
||||
unifiedLines.push({ type: 'removed', lineNumber: oldLineNum, content: contentLine.substring(1) });
|
||||
oldLineNum++;
|
||||
} else if (contentLine.startsWith(' ')) {
|
||||
unifiedLines.push({ type: 'context', lineNumber: lineNum, content: contentLine.substring(1) });
|
||||
lineNum++;
|
||||
unifiedLines.push({ type: 'context', lineNumber: newLineNum, content: contentLine.substring(1) });
|
||||
oldLineNum++;
|
||||
newLineNum++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user