Skip to content

Commit 14e8975

Browse files
committed
Refine clipboard parsing logic by simplifying regex patterns and ensuring file path hints are correctly handled across diff, completion, and multiple file parsers
1 parent e4e6b46 commit 14e8975

3 files changed

Lines changed: 4 additions & 19 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const normalize_header_line = (params: {
2424
}): string => {
2525
const processed_line = params.line
2626
.replace(/\s+\d{4}-\d{2}-\d{2}.*$/, '')
27-
.replace(/\t.*$/, '')
2827

2928
if (processed_line.startsWith('--- ')) {
3029
let path_part = processed_line.substring(4).trim()

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import {
88
const extract_path_and_position = (
99
line: string
1010
): { path: string; line: number; character: number } | null => {
11-
const path_pos_regex =
12-
/(?:\/\/|#|--|<!--)\s*"?([^"<>\s?*|:]+)"?\s+(\d+):(\d+)|(?:\/\*)\s*"?([^"<>\s?*|:]+)"?\s+(\d+):(\d+)|\*\s*"?([^"<>\s?*|:]+)"?\s+(\d+):(\d+)/
11+
const path_pos_regex = /\/\/\s*"?([^"<>\s?*|:]+)"?\s+(\d+):(\d+)/
1312

1413
const match = line.match(path_pos_regex)
1514

1615
if (match) {
17-
const path = match[1] || match[4] || match[7]
18-
const line_num_str = match[2] || match[5] || match[8]
19-
const char_num_str = match[3] || match[6] || match[9]
16+
const path = match[1]
17+
const line_num_str = match[2]
18+
const char_num_str = match[3]
2019

2120
if (path && line_num_str && char_num_str) {
2221
return {

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ export const parse_multiple_files = (params: {
6464

6565
if (!extracted_filename) {
6666
current_text_block += before_backticks
67-
} else {
68-
// A filename was extracted. Only add to text block if there's other text.
69-
const trimmed = before_backticks.trim()
70-
// If it doesn't start with a known comment marker, assume it's text.
71-
if (!/^\s*(<!--|#|\/\/|\/\*|--)/.test(trimmed)) {
72-
current_text_block += before_backticks
73-
}
7467
}
7568

7669
if (current_text_block.trim()) {
@@ -244,12 +237,6 @@ export const parse_multiple_files = (params: {
244237
}
245238
current_text_block = ''
246239
last_seen_file_path_comment = extracted_filename
247-
248-
const trimmed = line.trim()
249-
// If it doesn't start with a known comment marker, assume it's text.
250-
if (!/^\s*(<!--|#|\/\/|\/\*|--)/.test(trimmed)) {
251-
current_text_block += line + '\n'
252-
}
253240
} else {
254241
// Check if this line is a plain file path followed by a code block
255242
if (!last_seen_file_path_comment) {

0 commit comments

Comments
 (0)