diff --git a/package-lock.json b/package-lock.json index afffe45..a3410ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1056,6 +1056,7 @@ "integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.54.0", "@typescript-eslint/types": "8.54.0", @@ -1608,6 +1609,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2758,6 +2760,7 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -6120,6 +6123,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -6238,6 +6242,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/src/patchEditorProvider.ts b/src/patchEditorProvider.ts index 93d1354..ee07025 100644 --- a/src/patchEditorProvider.ts +++ b/src/patchEditorProvider.ts @@ -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()) { @@ -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' });