File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
src/integrations/terminal Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " roo-cline " : patch
3+ ---
4+
5+ Fix issue where the terminal management system was creating unnecessary new terminals (thanks @evan-fannin !)
Original file line number Diff line number Diff line change @@ -161,8 +161,10 @@ export class TerminalManager {
161161 }
162162
163163 async getOrCreateTerminal ( cwd : string ) : Promise < TerminalInfo > {
164+ const terminals = TerminalRegistry . getAllTerminals ( )
165+
164166 // Find available terminal from our pool first (created for this task)
165- const availableTerminal = TerminalRegistry . getAllTerminals ( ) . find ( ( t ) => {
167+ const matchingTerminal = terminals . find ( ( t ) => {
166168 if ( t . busy ) {
167169 return false
168170 }
@@ -173,11 +175,21 @@ export class TerminalManager {
173175 }
174176 return arePathsEqual ( vscode . Uri . file ( cwd ) . fsPath , terminalCwd . fsPath )
175177 } )
178+ if ( matchingTerminal ) {
179+ this . terminalIds . add ( matchingTerminal . id )
180+ return matchingTerminal
181+ }
182+
183+ // If no matching terminal exists, try to find any non-busy terminal
184+ const availableTerminal = terminals . find ( ( t ) => ! t . busy )
176185 if ( availableTerminal ) {
186+ // Navigate back to the desired directory
187+ await this . runCommand ( availableTerminal , `cd "${ cwd } "` )
177188 this . terminalIds . add ( availableTerminal . id )
178189 return availableTerminal
179190 }
180191
192+ // If all terminals are busy, create a new one
181193 const newTerminalInfo = TerminalRegistry . createTerminal ( cwd )
182194 this . terminalIds . add ( newTerminalInfo . id )
183195 return newTerminalInfo
You can’t perform that action at this time.
0 commit comments