Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/patchEditorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,17 @@ export class PatchEditorProvider implements vscode.CustomTextEditorProvider {
});
}

// Strip git format-patch footer (e.g., "-- \n2.43.0\n")
// This footer is added by git format-patch and should not be parsed as diff content
function stripGitPatchFooter(content) {
if (!content) return content;
// Match the git email signature footer: "-- " followed by newline and version info
// The footer starts with "-- " on its own line (with possible trailing whitespace)
// followed by a git version number (e.g., "2.43.0") on the next line
var footerPattern = new RegExp('\\n-- \\n[0-9]+\\.[0-9]+[^\\n]*\\n?$');
return content.replace(footerPattern, '\n');
}

// Render diff using diff2html
function renderDiff() {
if (!currentContent || !currentContent.trim()) {
Expand All @@ -892,8 +903,11 @@ export class PatchEditorProvider implements vscode.CustomTextEditorProvider {
try {
const outputFormat = currentViewMode === 'side-by-side' ? 'side-by-side' : 'line-by-line';

// Strip git format-patch footer before parsing
const contentToParse = stripGitPatchFooter(currentContent);

// First, try to parse the diff content
const diffJson = Diff2HtmlLib.parse(currentContent, {
const diffJson = Diff2HtmlLib.parse(contentToParse, {
inputFormat: 'diff'
});

Expand Down