From d948fc5950fb1a3d3921fdd101aef2afa9f09223 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 3 Aug 2025 19:06:52 -0400 Subject: [PATCH 1/4] Updated code selection to properly parse selected lines --- .../workbench/contrib/void/common/prompt/prompts.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/void/common/prompt/prompts.ts b/src/vs/workbench/contrib/void/common/prompt/prompts.ts index 55412a80..c31fdb40 100644 --- a/src/vs/workbench/contrib/void/common/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/common/prompt/prompts.ts @@ -575,13 +575,21 @@ export const messageOfSelection = async ( ) => { const lineNumAddition = (range: [number, number]) => ` (lines ${range[0]}:${range[1]})` - if (s.type === 'File' || s.type === 'CodeSelection') { + if (s.type === 'CodeSelection') { const { val } = await readFile(opts.fileService, s.uri, DEFAULT_FILE_SIZE_LIMIT) const lineNumAdd = s.type === 'CodeSelection' ? lineNumAddition(s.range) : '' - const content = val === null ? 'null' : `${tripleTick[0]}${s.language}\n${val}\n${tripleTick[1]}` + const lines = val?.split('\n') + const selection = lines?.slice(s.range[0] - 1, s.range[1]).join('\n') + const content = selection ?? 'null' const str = `${s.uri.fsPath}${lineNumAdd}:\n${content}` return str } + else if (s.type === 'File') { + const { val } = await readFile(opts.fileService, s.uri, DEFAULT_FILE_SIZE_LIMIT) + const content = val === null ? 'null' : `${tripleTick[0]}${s.language}\n${val}\n${tripleTick[1]}` + const str = `${s.uri.fsPath}:\n${content}` + return str + } else if (s.type === 'Folder') { const dirStr: string = await opts.directoryStrService.getDirectoryStrTool(s.uri) const folderStructure = `${s.uri.fsPath} folder structure:${tripleTick[0]}\n${dirStr}\n${tripleTick[1]}` From cbb52dec286a50bdc91af02d3e89d010dbe95b75 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 4 Aug 2025 10:55:59 -0400 Subject: [PATCH 2/4] Removed unnecessary ternary in lineNumAdd --- src/vs/workbench/contrib/void/common/prompt/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/void/common/prompt/prompts.ts b/src/vs/workbench/contrib/void/common/prompt/prompts.ts index c31fdb40..9c737193 100644 --- a/src/vs/workbench/contrib/void/common/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/common/prompt/prompts.ts @@ -577,7 +577,7 @@ export const messageOfSelection = async ( if (s.type === 'CodeSelection') { const { val } = await readFile(opts.fileService, s.uri, DEFAULT_FILE_SIZE_LIMIT) - const lineNumAdd = s.type === 'CodeSelection' ? lineNumAddition(s.range) : '' + const lineNumAdd = lineNumAddition(s.range) const lines = val?.split('\n') const selection = lines?.slice(s.range[0] - 1, s.range[1]).join('\n') const content = selection ?? 'null' From 7a974f2dff094c1ce858036dd8f912f1da792bcc Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 4 Aug 2025 14:23:35 -0400 Subject: [PATCH 3/4] Fixed selection output to include triple backticks and language tag --- src/vs/workbench/contrib/void/common/prompt/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/void/common/prompt/prompts.ts b/src/vs/workbench/contrib/void/common/prompt/prompts.ts index 9c737193..973dc493 100644 --- a/src/vs/workbench/contrib/void/common/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/common/prompt/prompts.ts @@ -579,7 +579,7 @@ export const messageOfSelection = async ( const { val } = await readFile(opts.fileService, s.uri, DEFAULT_FILE_SIZE_LIMIT) const lineNumAdd = lineNumAddition(s.range) const lines = val?.split('\n') - const selection = lines?.slice(s.range[0] - 1, s.range[1]).join('\n') + const selection = `${tripleTick[0]}${s.language}\n${lines?.slice(s.range[0] - 1, s.range[1]).join('\n')}\n${tripleTick[1]}` const content = selection ?? 'null' const str = `${s.uri.fsPath}${lineNumAdd}:\n${content}` return str From ff717cad1688492f858052ef4c1f57abcbb75b0a Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 4 Aug 2025 15:21:42 -0700 Subject: [PATCH 4/4] update lines --- .../contrib/void/common/prompt/prompts.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/void/common/prompt/prompts.ts b/src/vs/workbench/contrib/void/common/prompt/prompts.ts index 973dc493..fba76815 100644 --- a/src/vs/workbench/contrib/void/common/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/common/prompt/prompts.ts @@ -577,16 +577,21 @@ export const messageOfSelection = async ( if (s.type === 'CodeSelection') { const { val } = await readFile(opts.fileService, s.uri, DEFAULT_FILE_SIZE_LIMIT) - const lineNumAdd = lineNumAddition(s.range) const lines = val?.split('\n') - const selection = `${tripleTick[0]}${s.language}\n${lines?.slice(s.range[0] - 1, s.range[1]).join('\n')}\n${tripleTick[1]}` - const content = selection ?? 'null' - const str = `${s.uri.fsPath}${lineNumAdd}:\n${content}` + + const innerVal = lines?.slice(s.range[0] - 1, s.range[1]).join('\n') + const content = !lines ? '' + : `${tripleTick[0]}${s.language}\n${innerVal}\n${tripleTick[1]}` + const str = `${s.uri.fsPath}${lineNumAddition(s.range)}:\n${content}` return str } else if (s.type === 'File') { const { val } = await readFile(opts.fileService, s.uri, DEFAULT_FILE_SIZE_LIMIT) - const content = val === null ? 'null' : `${tripleTick[0]}${s.language}\n${val}\n${tripleTick[1]}` + + const innerVal = val + const content = val === null ? '' + : `${tripleTick[0]}${s.language}\n${innerVal}\n${tripleTick[1]}` + const str = `${s.uri.fsPath}:\n${content}` return str }