Skip to content

Commit f72eb3f

Browse files
committed
Correct the clipboard parser to accurately label extracted file content blocks as type 'file' instead of type 'diff'
1 parent a07c80d commit f72eb3f

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

‎packages/vscode/src/commands/apply-chat-response-command/response-processor.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ export const process_chat_response = async (
153153
]
154154
}
155155

156+
console.log('xxx', clipboard_items)
157+
156158
if (clipboard_items.some((item) => item.type == 'diff')) {
157159
const patches = clipboard_items.filter(
158160
(item): item is DiffItem => item.type == 'diff'

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ describe('clipboard-parser', () => {
10001000
content: load_test_case_file(test_case, '1-text.txt')
10011001
})
10021002
expect(result[1]).toMatchObject({
1003-
type: 'diff',
1003+
type: 'file',
10041004
file_path: 'src/lorem.ts',
10051005
content: load_test_case_file(test_case, '2-file.txt')
10061006
})
@@ -1009,7 +1009,7 @@ describe('clipboard-parser', () => {
10091009
content: load_test_case_file(test_case, '3-text.txt')
10101010
})
10111011
expect(result[3]).toMatchObject({
1012-
type: 'diff',
1012+
type: 'file',
10131013
file_path: 'src/ipsum.ts',
10141014
content: load_test_case_file(test_case, '4-file.txt')
10151015
})

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ export const parse_response = (params: {
130130

131131
return items.map((item) => {
132132
if ('file_path' in item) {
133-
const file = item as ClipboardFile
134-
// The test expects a 'diff' type item even for new files.
135-
// And the content is expected to be the raw file content, not a patch.
136-
// This is inconsistent but we follow the test.
137-
return { type: 'diff', ...file }
133+
return { type: 'file', ...(item as ClipboardFile) }
138134
}
139135
return item as TextItem
140136
})

0 commit comments

Comments
 (0)