Skip to content

Commit 49857dc

Browse files
committed
Preserve non-comment lines containing file paths as text when parsing responses
1 parent 83200e3 commit 49857dc

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,16 @@ export const parse_multiple_files = (params: {
195195
}
196196
current_text_block = ''
197197
last_seen_file_path_comment = extracted_filename
198-
} else if (!last_seen_file_path_comment) {
199-
current_text_block += line + '\n'
198+
199+
const trimmed = line.trim()
200+
// If it doesn't start with a known comment marker, assume it's text.
201+
if (!/^\s*(<!--|#|\/\/|\/\*|--)/.test(trimmed)) {
202+
current_text_block += line + '\n'
203+
}
204+
} else {
205+
if (!last_seen_file_path_comment) {
206+
current_text_block += line + '\n'
207+
}
200208
}
201209
} else if (state == 'CONTENT') {
202210
if (top_level_xml_file_mode) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Top. `abc.ts`
1+
Top. `top.ts`

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/test-cases/text-between/text-between.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Top. `abc.ts`
1+
Top. `top.ts`
22

33
```ts
44
// src/lorem.ts

0 commit comments

Comments
 (0)