@@ -186,15 +186,22 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
186
186
} ) ;
187
187
const language = os === OperatingSystem . Windows ? 'pwsh' : 'sh' ;
188
188
189
+ const instance = context . chatSessionId ? this . _sessionTerminalAssociations . get ( context . chatSessionId ) ?. instance : undefined ;
190
+ let toolEditedCommand : string | undefined = await this . _rewriteCommandIfNeeded ( args , instance , shell ) ;
191
+ if ( toolEditedCommand === args . command ) {
192
+ toolEditedCommand = undefined ;
193
+ }
194
+
189
195
let confirmationMessages : IToolConfirmationMessages | undefined ;
190
196
if ( this . _alternativeRecommendation ) {
191
197
confirmationMessages = undefined ;
192
198
} else {
193
- const subCommands = splitCommandLineIntoSubCommands ( args . command , shell , os ) ;
199
+ const actualCommand = toolEditedCommand ?? args . command ;
200
+ const subCommands = splitCommandLineIntoSubCommands ( actualCommand , shell , os ) ;
194
201
const inlineSubCommands = subCommands . map ( e => Array . from ( extractInlineSubCommands ( e , shell , os ) ) ) . flat ( ) ;
195
202
const allSubCommands = [ ...subCommands , ...inlineSubCommands ] ;
196
203
const subCommandResults = allSubCommands . map ( e => this . _commandLineAutoApprover . isCommandAutoApproved ( e , shell , os ) ) ;
197
- const commandLineResult = this . _commandLineAutoApprover . isCommandLineAutoApproved ( args . command ) ;
204
+ const commandLineResult = this . _commandLineAutoApprover . isCommandLineAutoApproved ( actualCommand ) ;
198
205
const autoApproveReasons : string [ ] = [
199
206
...subCommandResults . map ( e => e . reason ) ,
200
207
commandLineResult . reason ,
@@ -233,12 +240,6 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
233
240
} ;
234
241
}
235
242
236
- const instance = context . chatSessionId ? this . _sessionTerminalAssociations . get ( context . chatSessionId ) ?. instance : undefined ;
237
- let toolEditedCommand : string | undefined = await this . _rewriteCommandIfNeeded ( args , instance , shell ) ;
238
- if ( toolEditedCommand === args . command ) {
239
- toolEditedCommand = undefined ;
240
- }
241
-
242
243
return {
243
244
confirmationMessages,
244
245
presentation,
0 commit comments