Skip to content

Commit be4695b

Browse files
committed
Update the clipboard parser to correctly handle CDATA blocks embedded within markdown code blocks
1 parent dd9ad0b commit be4695b

5 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎packages/vscode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
4-
"description": "CWC—Blazing fast AI pair programming",
4+
"description": "Blazing fast AI pair programming for production-grade code. Select context as you go for pro accuracy and game-changing speed. (CWC)",
55
"version": "1.495.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ describe('clipboard-parser', () => {
6161
})
6262
})
6363

64+
it('parses file when CDATA is present inside a markdown code block with a comment filename', () => {
65+
const test_case = 'cdata-inside-code-block'
66+
const text = load_test_case_file(test_case, `${test_case}.txt`)
67+
const result = parse_multiple_files({
68+
response: text,
69+
is_single_root_folder_workspace: true
70+
})
71+
72+
expect(result).toHaveLength(1)
73+
expect(result[0]).toMatchObject({
74+
file_path: 'src/index.ts',
75+
content: load_test_case_file(test_case, '1-file.txt')
76+
})
77+
})
78+
6479
it('parses file when using file-xml format with CDATA inside a markdown code block', () => {
6580
const test_case = 'file-xml-with-cdata-inside-code-block'
6681
const text = load_test_case_file(test_case, `${test_case}.txt`)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,12 @@ export const parse_multiple_files = (params: {
474474
}
475475
}
476476

477-
if (xml_file_mode && line.trim().startsWith('<![CDATA[')) {
477+
if (line.trim().startsWith('<![CDATA[')) {
478478
in_cdata = true
479479
continue
480480
}
481481

482-
if (xml_file_mode && in_cdata && line.trim().includes(']]>')) {
482+
if (in_cdata && line.trim().includes(']]>')) {
483483
in_cdata = false
484484
continue
485485
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("hello")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```typescript
2+
// src/index.ts
3+
<![CDATA[
4+
console.log("hello")
5+
]]>
6+
```

0 commit comments

Comments
 (0)