Skip to content

Commit 5584353

Browse files
committed
Enhance file path parsing to correctly identify and separate plain text file paths preceding a code block from surrounding narrative text
1 parent 14e8975 commit 5584353

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,15 @@ describe('clipboard-parser', () => {
498498
is_single_root_folder_workspace: true
499499
})
500500

501-
expect(result).toHaveLength(1)
501+
expect(result).toHaveLength(2)
502502
expect(result[0]).toMatchObject({
503+
type: 'text',
504+
content: load_test_case_file(test_case, '1-text.txt')
505+
})
506+
expect(result[1]).toMatchObject({
503507
type: 'file',
504508
file_path: 'src/hello-world.ts',
505-
content: load_test_case_file(test_case, '1-file.txt')
509+
content: load_test_case_file(test_case, '2-file.txt')
506510
})
507511
})
508512

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export const parse_multiple_files = (params: {
239239
last_seen_file_path_comment = extracted_filename
240240
} else {
241241
// Check if this line is a plain file path followed by a code block
242+
let is_lone_path_on_this_line = false
242243
if (!last_seen_file_path_comment) {
243244
let trimmed = line.trim()
244245

@@ -275,10 +276,11 @@ export const parse_multiple_files = (params: {
275276
}
276277
if (is_followed_by_code_block) {
277278
last_seen_file_path_comment = trimmed
279+
is_lone_path_on_this_line = true
278280
}
279281
}
280282
}
281-
if (!last_seen_file_path_comment) {
283+
if (!is_lone_path_on_this_line) {
282284
current_text_block += line + '\n'
283285
}
284286
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This new file

packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/test-cases/path-above-code-block/1-file.txt renamed to packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/test-cases/path-above-code-block/2-file.txt

File renamed without changes.

0 commit comments

Comments
 (0)