Skip to content

Commit 2bacbcf

Browse files
committed
Enhance clipboard parsing to correctly identify file paths within various comment types preceding a code block
1 parent 5584353 commit 2bacbcf

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎packages/vscode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "Superfast AI coding (CWC)",
5-
"version": "1.607.0",
5+
"version": "1.608.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,19 @@ export const parse_multiple_files = (params: {
196196

197197
// Avoid matching file paths that are part of a sentence.
198198
if (!(/[a-zA-Z]/.test(before) && /[a-zA-Z]/.test(after))) {
199-
const is_markdown_header = line.trim().startsWith('#')
199+
const trimmed_line = line.trim()
200+
const is_comment_or_header =
201+
trimmed_line.startsWith('#') ||
202+
trimmed_line.startsWith('//') ||
203+
trimmed_line.startsWith('/*') ||
204+
trimmed_line.startsWith('*') ||
205+
trimmed_line.startsWith('--') ||
206+
trimmed_line.startsWith('<!--')
200207
let is_followed_by_code_block = false
201208
for (let j = i + 1; j < lines.length; j++) {
202209
const next_line = lines[j].trim()
203210
if (next_line.startsWith('```')) {
204-
if (is_markdown_header) {
211+
if (is_comment_or_header) {
205212
is_followed_by_code_block = true
206213
} else {
207214
let all_intermediate_lines_empty = true

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/test-cases/path-above-code-block/path-above-code-block.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
### New File: `src/hello-world.ts`
2+
// `src/hello-world.ts`
33

44
This new file
55

0 commit comments

Comments
 (0)