Skip to content

Commit 02cd7d3

Browse files
committed
Remove the feature that adds line numbers to collected file content and update the diff format instruction
1 parent 141b63c commit 02cd7d3

5 files changed

Lines changed: 5 additions & 26 deletions

File tree

packages/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
"type": "string",
651651
"scope": "resource",
652652
"description": "Style instructions for chat responses when using diff format.",
653-
"default": "Whenever proposing a file use the markdown code block syntax. Each code block should be a diff patch without line numbers."
653+
"default": "Whenever proposing a file use the markdown code block syntax. Each code block should be a diff patch."
654654
},
655655
"codeWebChat.chatCodeCompletionsInstructions": {
656656
"type": "string",

packages/vscode/src/helpers/files-collector.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class FilesCollector {
2727
disable_xml?: boolean
2828
exclude_path?: string
2929
active_path?: string
30-
with_line_numbers?: boolean
3130
}): Promise<string> {
3231
const workspace_files = this.workspace_provider.get_checked_files()
3332
const open_editor_files =
@@ -59,11 +58,7 @@ export class FilesCollector {
5958

6059
if (stats.isDirectory()) continue
6160

62-
let content = fs.readFileSync(file_path, 'utf8')
63-
64-
if (params?.with_line_numbers) {
65-
content = this.add_line_numbers(content)
66-
}
61+
const content = fs.readFileSync(file_path, 'utf8')
6762

6863
// Find which workspace root this file belongs to
6964
const workspace_root = this.get_workspace_root_for_file(file_path)
@@ -108,19 +103,6 @@ export class FilesCollector {
108103
return collected_text
109104
}
110105

111-
private add_line_numbers(content: string): string {
112-
const lines = content.split('\n')
113-
const max_line_number = lines.length
114-
const padding = max_line_number.toString().length
115-
116-
return lines
117-
.map((line, index) => {
118-
const line_number = (index + 1).toString().padStart(padding, ' ')
119-
return `${line_number} ${line}`
120-
})
121-
.join('\n')
122-
}
123-
124106
private get_workspace_root_for_file(file_path: string): string | undefined {
125107
return this.workspace_provider.get_workspace_root_for_file(file_path)
126108
}

packages/vscode/src/view/backend/message-handlers/handle-copy-prompt.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export const handle_copy_prompt = async (
5252
} else if (!provider.is_code_completions_mode) {
5353
const active_path = active_editor?.document.uri.fsPath
5454
const context_text = await files_collector.collect_files({
55-
active_path,
56-
with_line_numbers: provider.edit_format == 'diff'
55+
active_path
5756
})
5857

5958
let instructions = replace_selection_placeholder(current_instruction)

packages/vscode/src/view/backend/message-handlers/handle-preview-preset.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ export const handle_preview_preset = async (
5454
text_to_send = `${instructions}\n<files>\n${context_text}<file path="${relative_path}">\n<![CDATA[\n${text_before_cursor}<missing text>${text_after_cursor}\n]]>\n</file>\n</files>\n${instructions}`
5555
} else if (!provider.is_code_completions_mode) {
5656
const context_text = await files_collector.collect_files({
57-
active_path,
58-
with_line_numbers: provider.edit_format == 'diff'
57+
active_path
5958
})
6059

6160
let instructions = replace_selection_placeholder(current_instructions)

packages/vscode/src/view/backend/message-handlers/handle-send-prompt.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ export const handle_send_prompt = async (
6767
if (!provider.instructions) return
6868

6969
const context_text = await files_collector.collect_files({
70-
active_path,
71-
with_line_numbers: provider.edit_format == 'diff'
70+
active_path
7271
})
7372

7473
let instructions = provider.instructions

0 commit comments

Comments
 (0)