Skip to content

Commit 03d9df8

Browse files
committed
Handle empty file content during rename by preserving original content and create file entries for renamed files during parsing
}
1 parent d4e657a commit 03d9df8

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ export const handle_fast_replace = async (
126126

127127
if (rename_source_path && rename_source_content !== undefined) {
128128
try {
129+
let new_content = file.content
130+
if (new_content == '') {
131+
new_content = rename_source_content
132+
}
133+
129134
const tabs_to_close: vscode.Tab[] = []
130135
for (const tab_group of vscode.window.tabGroups.all) {
131136
tabs_to_close.push(
@@ -154,7 +159,7 @@ export const handle_fast_replace = async (
154159
}
155160
await vscode.workspace.fs.writeFile(
156161
vscode.Uri.file(safe_path),
157-
Buffer.from(file.content, 'utf8')
162+
Buffer.from(new_content, 'utf8')
158163
)
159164

160165
const document = await vscode.workspace.openTextDocument(safe_path)

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/parsers/multiple-files-parser.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,24 @@ export const parse_multiple_files = (params: {
392392

393393
renamed_from_path = relative_path
394394

395+
const {
396+
relative_path: new_relative_path,
397+
workspace_name: new_workspace_name
398+
} = extract_and_set_workspace_path({
399+
raw_file_path: renamed_file_match[2],
400+
is_single_root_folder_workspace:
401+
params.is_single_root_folder_workspace
402+
})
403+
404+
create_or_update_file_item({
405+
file_name: new_relative_path,
406+
content: '',
407+
workspace_name: new_workspace_name,
408+
file_ref_map,
409+
results,
410+
renamed_from: renamed_from_path
411+
})
412+
395413
last_seen_file_path_comment = renamed_file_match[2]
396414
last_seen_file_path_was_header = true
397415
header_path_already_used = false

0 commit comments

Comments
 (0)