@@ -609,30 +609,32 @@ export class ChatController {
609609
610610 const absoluteFilePath = path . join ( projectRoot , message . filePath )
611611
612- // Open the file in VSCode
613- const document = await workspace . openTextDocument ( absoluteFilePath )
614- const editor = await window . showTextDocument ( document , ViewColumn . Active )
615-
616- // Create multiple selections based on line ranges
617- const selections : Selection [ ] = lineRanges
618- . filter ( ( { first, second } ) => first !== - 1 && second !== - 1 )
619- . map ( ( { first, second } ) => {
620- const startPosition = new Position ( first - 1 , 0 ) // Convert 1-based to 0-based
621- const endPosition = new Position ( second - 1 , document . lineAt ( second - 1 ) . range . end . character )
622- return new Selection (
623- startPosition . line ,
624- startPosition . character ,
625- endPosition . line ,
626- endPosition . character
627- )
628- } )
612+ try {
613+ // Open the file in VSCode
614+ const document = await workspace . openTextDocument ( absoluteFilePath )
615+ const editor = await window . showTextDocument ( document , ViewColumn . Active )
616+
617+ // Create multiple selections based on line ranges
618+ const selections : Selection [ ] = lineRanges
619+ . filter ( ( { first, second } ) => first !== - 1 && second !== - 1 )
620+ . map ( ( { first, second } ) => {
621+ const startPosition = new Position ( first - 1 , 0 ) // Convert 1-based to 0-based
622+ const endPosition = new Position ( second - 1 , document . lineAt ( second - 1 ) . range . end . character )
623+ return new Selection (
624+ startPosition . line ,
625+ startPosition . character ,
626+ endPosition . line ,
627+ endPosition . character
628+ )
629+ } )
629630
630- // Apply multiple selections to the editor using the new API
631- if ( selections . length > 0 ) {
632- editor . selection = selections [ 0 ] // Set the first selection as active
633- editor . selections = selections // Apply multiple selections
634- editor . revealRange ( selections [ 0 ] , vscode . TextEditorRevealType . InCenter )
635- }
631+ // Apply multiple selections to the editor
632+ if ( selections . length > 0 ) {
633+ editor . selection = selections [ 0 ] // Set the first selection as active
634+ editor . selections = selections // Apply multiple selections
635+ editor . revealRange ( selections [ 0 ] , vscode . TextEditorRevealType . InCenter )
636+ }
637+ } catch ( error ) { }
636638 }
637639
638640 private processException ( e : any , tabID : string ) {
@@ -889,16 +891,16 @@ export class ChatController {
889891 for ( const context of triggerPayload . context ) {
890892 if ( typeof context !== 'string' && context . route && context . route . length === 2 ) {
891893 contextCommands . push ( {
892- workspaceFolder : context . route ?. [ 0 ] || '' ,
894+ workspaceFolder : context . route [ 0 ] || '' ,
893895 type : context . icon === 'folder' ? 'folder' : 'file' ,
894- relativePath : context . route ?. [ 1 ] || '' ,
896+ relativePath : context . route [ 1 ] || '' ,
895897 } )
896- relativePaths . push ( context . route [ 1 ] )
897898 }
898899 }
899900 if ( contextCommands . length === 0 ) {
900901 return [ ]
901902 }
903+ const workspaceFolder = contextCommands [ 0 ] . workspaceFolder
902904 const prompts = await LspClient . instance . getContextCommandPrompt ( contextCommands )
903905 if ( prompts . length > 0 ) {
904906 triggerPayload . additionalContents = [ ]
@@ -910,6 +912,8 @@ export class ChatController {
910912 description : prompt . description . substring ( 0 , aditionalContentNameLimit ) ,
911913 innerContext : prompt . content . substring ( 0 , additionalContentInnerContextLimit ) ,
912914 } )
915+ const relativePath = path . relative ( workspaceFolder , prompt . filePath )
916+ relativePaths . push ( relativePath )
913917 }
914918 }
915919 getLogger ( ) . info (
0 commit comments