Skip to content

Commit d5049f5

Browse files
committed
Disable --ignore-whitespace flag for Python files during git apply to preserve indentation
1 parent 53081fe commit d5049f5

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

  • packages/vscode/src/commands/apply-chat-response-command/handlers

‎packages/vscode/src/commands/apply-chat-response-command/handlers/diff-handler.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,20 @@ export const apply_git_patch = async (
485485
// Attempt 1: git apply with --recount
486486
if (!success) {
487487
try {
488-
await execAsync(
489-
`git apply --whitespace=fix --ignore-whitespace --recount "${temp_file}"`,
490-
{ cwd: workspace_path }
488+
const contains_python_file = file_paths.some((path) =>
489+
path.toLowerCase().endsWith('.py')
491490
)
491+
const flags = [
492+
'--whitespace=fix',
493+
contains_python_file ? '' : '--ignore-whitespace',
494+
'--recount'
495+
]
496+
.filter(Boolean)
497+
.join(' ')
498+
499+
await execAsync(`git apply ${flags} "${temp_file}"`, {
500+
cwd: workspace_path
501+
})
492502
success = true
493503
diff_application_method = 'recount'
494504
Logger.info({

0 commit comments

Comments
 (0)