Skip to content

Commit 9f07d77

Browse files
committed
Refine file path extraction logic to correctly identify paths enclosed in backticks path/to/file.ext when they immediately precede a code block, even if intermediate lines are empty
1 parent 3e37bea commit 9f07d77

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,25 @@ export const parse_multiple_files = (params: {
199199

200200
// Avoid matching file paths that are part of a sentence.
201201
if (!(/[a-zA-Z]/.test(before) && /[a-zA-Z]/.test(after))) {
202+
const is_markdown_header = line.trim().startsWith('#')
202203
let is_followed_by_code_block = false
203204
for (let j = i + 1; j < lines.length; j++) {
204205
const next_line = lines[j].trim()
205206
if (next_line.startsWith('```')) {
206-
is_followed_by_code_block = true
207+
if (is_markdown_header) {
208+
is_followed_by_code_block = true
209+
} else {
210+
let all_intermediate_lines_empty = true
211+
for (let k = i + 1; k < j; k++) {
212+
if (lines[k].trim() !== '') {
213+
all_intermediate_lines_empty = false
214+
break
215+
}
216+
}
217+
if (all_intermediate_lines_empty) {
218+
is_followed_by_code_block = true
219+
}
220+
}
207221
break
208222
}
209223
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
Top. `top.ts`
1+
I have removed all comments from the provided files.
2+
3+
The changes are:
4+
5+
1. **`daemon.ts`**: Removed numerous inline comments explaining steps like API calls, file downloads, directory preparation, and cleanup.
6+
2. **`src/index.ts`**: Removed the comment explaining the aspect ratio check.
7+
3. **`src/tasks/clean-from-people.ts`**: Removed the comment describing the file movement logic after running the tourist filter script.
8+
4. **`src/tasks/stitch-dslr-images.ts`**: Removed comments explaining the purpose of checking for `project.pto` and the logic for replacing image path placeholders within the `.pto` file content.
9+
10+
Here are the updated files:

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/test-cases/text-between/text-between.txt‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
Top. `top.ts`
1+
I have removed all comments from the provided files.
2+
3+
The changes are:
4+
5+
1. **`daemon.ts`**: Removed numerous inline comments explaining steps like API calls, file downloads, directory preparation, and cleanup.
6+
2. **`src/index.ts`**: Removed the comment explaining the aspect ratio check.
7+
3. **`src/tasks/clean-from-people.ts`**: Removed the comment describing the file movement logic after running the tourist filter script.
8+
4. **`src/tasks/stitch-dslr-images.ts`**: Removed comments explaining the purpose of checking for `project.pto` and the logic for replacing image path placeholders within the `.pto` file content.
9+
10+
Here are the updated files:
211

312
```ts
413
// src/lorem.ts

0 commit comments

Comments
 (0)