@@ -198,7 +198,7 @@ export function registerContextualInstanceAction(
198198 return registerTerminalAction ( {
199199 ...options ,
200200 run : async ( c , accessor , focusedInstanceArgs , allInstanceArgs ) => {
201- let instances = getSelectedInstances2 ( accessor , allInstanceArgs ) ;
201+ let instances = getSelectedViewInstances2 ( accessor , allInstanceArgs ) ;
202202 if ( ! instances ) {
203203 const activeInstance = (
204204 options . activeInstanceType === 'view'
@@ -722,7 +722,7 @@ export function registerTerminalActions() {
722722 getResourceOrActiveInstance ( c , args ) ?. changeIcon ( ) ;
723723 return ;
724724 }
725- for ( const terminal of getSelectedInstances ( accessor ) ?? [ ] ) {
725+ for ( const terminal of getSelectedViewInstances ( accessor ) ?? [ ] ) {
726726 icon = await terminal . changeIcon ( icon ) ;
727727 }
728728 }
@@ -747,7 +747,7 @@ export function registerTerminalActions() {
747747 getResourceOrActiveInstance ( c , args ) ?. changeColor ( ) ;
748748 return ;
749749 }
750- for ( const terminal of getSelectedInstances ( accessor ) ?? [ ] ) {
750+ for ( const terminal of getSelectedViewInstances ( accessor ) ?? [ ] ) {
751751 const skipQuickPick = i !== 0 ;
752752 // Always show the quickpick on the first iteration
753753 color = await terminal . changeColor ( color , skipQuickPick ) ;
@@ -779,7 +779,7 @@ export function registerTerminalActions() {
779779 run : async ( c , accessor ) => {
780780 const terminalGroupService = accessor . get ( ITerminalGroupService ) ;
781781 const notificationService = accessor . get ( INotificationService ) ;
782- const instances = getSelectedInstances ( accessor ) ;
782+ const instances = getSelectedViewInstances ( accessor ) ;
783783 const firstInstance = instances ?. [ 0 ] ;
784784 if ( ! firstInstance ) {
785785 return ;
@@ -1093,7 +1093,7 @@ export function registerTerminalActions() {
10931093 when : TerminalContextKeys . tabsFocus
10941094 } ,
10951095 run : async ( c , accessor ) => {
1096- const instances = getSelectedInstances ( accessor ) ;
1096+ const instances = getSelectedViewInstances ( accessor ) ;
10971097 if ( instances ) {
10981098 const promises : Promise < void > [ ] = [ ] ;
10991099 for ( const t of instances ) {
@@ -1124,7 +1124,7 @@ export function registerTerminalActions() {
11241124 title : localize2 ( 'workbench.action.terminal.joinInstance' , 'Join Terminals' ) ,
11251125 precondition : ContextKeyExpr . and ( sharedWhenClause . terminalAvailable , TerminalContextKeys . tabsSingularSelection . toNegated ( ) ) ,
11261126 run : async ( c , accessor ) => {
1127- const instances = getSelectedInstances ( accessor ) ;
1127+ const instances = getSelectedViewInstances ( accessor ) ;
11281128 if ( instances && instances . length > 1 ) {
11291129 c . groupService . joinInstances ( instances ) ;
11301130 }
@@ -1328,7 +1328,7 @@ export function registerTerminalActions() {
13281328 } ,
13291329 run : async ( c , accessor ) => {
13301330 const disposePromises : Promise < void > [ ] = [ ] ;
1331- for ( const terminal of getSelectedInstances ( accessor , true ) ?? [ ] ) {
1331+ for ( const terminal of getSelectedViewInstances ( accessor , true ) ?? [ ] ) {
13321332 disposePromises . push ( c . service . safeDisposeTerminal ( terminal ) ) ;
13331333 }
13341334 await Promise . all ( disposePromises ) ;
@@ -1447,7 +1447,7 @@ interface IRemoteTerminalPick extends IQuickPickItem {
14471447 term : IRemoteTerminalAttachTarget ;
14481448}
14491449
1450- function getSelectedInstances2 ( accessor : ServicesAccessor , args ?: unknown ) : ITerminalInstance [ ] | undefined {
1450+ function getSelectedViewInstances2 ( accessor : ServicesAccessor , args ?: unknown ) : ITerminalInstance [ ] | undefined {
14511451 const terminalService = accessor . get ( ITerminalService ) ;
14521452 const result : ITerminalInstance [ ] = [ ] ;
14531453 const context = parseActionArgs ( args ) ;
@@ -1465,9 +1465,8 @@ function getSelectedInstances2(accessor: ServicesAccessor, args?: unknown): ITer
14651465 return undefined ;
14661466}
14671467
1468- function getSelectedInstances ( accessor : ServicesAccessor , args ?: unknown , args2 ?: unknown ) : ITerminalInstance [ ] | undefined {
1468+ function getSelectedViewInstances ( accessor : ServicesAccessor , args ?: unknown , args2 ?: unknown ) : ITerminalInstance [ ] | undefined {
14691469 const listService = accessor . get ( IListService ) ;
1470- const terminalService = accessor . get ( ITerminalService ) ;
14711470 const terminalGroupService = accessor . get ( ITerminalGroupService ) ;
14721471 const result : ITerminalInstance [ ] = [ ] ;
14731472
@@ -1486,16 +1485,17 @@ function getSelectedInstances(accessor: ServicesAccessor, args?: unknown, args2?
14861485 }
14871486 const focused = list . getFocus ( ) ;
14881487
1488+ const viewInstances = terminalGroupService . instances ;
14891489 if ( focused . length === 1 && ! selections . includes ( focused [ 0 ] ) ) {
14901490 // focused length is always a max of 1
14911491 // if the focused one is not in the selected list, return that item
1492- result . push ( terminalService . getInstanceFromIndex ( focused [ 0 ] ) as ITerminalInstance ) ;
1492+ result . push ( viewInstances [ focused [ 0 ] ] ) ;
14931493 return result ;
14941494 }
14951495
14961496 // multi-select
14971497 for ( const selection of selections ) {
1498- result . push ( terminalService . getInstanceFromIndex ( selection ) as ITerminalInstance ) ;
1498+ result . push ( viewInstances [ selection ] ) ;
14991499 }
15001500 return result . filter ( r => ! ! r ) ;
15011501}
0 commit comments