@@ -186,7 +186,8 @@ export default class TabProxy extends Plugin {
186
186
this . call ( 'manager' , 'deactivatePlugin' , name )
187
187
} ,
188
188
icon ,
189
- description
189
+ description ,
190
+ show
190
191
)
191
192
show && this . switchTab ( name )
192
193
}
@@ -210,6 +211,10 @@ export default class TabProxy extends Plugin {
210
211
211
212
focus ( name ) {
212
213
this . emit ( 'switchApp' , name )
214
+ const tabIndex = this . loadedTabs . findIndex ( tab => tab . name === name )
215
+ if ( tabIndex !== - 1 ) {
216
+ this . loadedTabs [ tabIndex ] . show = true
217
+ }
213
218
this . tabsApi . activateTab ( name )
214
219
}
215
220
@@ -259,7 +264,7 @@ export default class TabProxy extends Plugin {
259
264
* @param {string } description
260
265
* @returns
261
266
*/
262
- addTab ( name , title , switchTo , close , icon , description = '' ) {
267
+ addTab ( name , title , switchTo , close , icon , description = '' , show = true ) {
263
268
if ( this . _handlers [ name ] ) return this . renderComponent ( )
264
269
265
270
if ( ( name . endsWith ( '.vy' ) && icon === undefined ) || title . includes ( 'Vyper' ) ) {
@@ -290,7 +295,8 @@ export default class TabProxy extends Plugin {
290
295
title,
291
296
icon,
292
297
tooltip : name ,
293
- iconClass : getPathIcon ( name )
298
+ iconClass : getPathIcon ( name ) ,
299
+ show
294
300
} )
295
301
formatPath . shift ( )
296
302
if ( formatPath . length > 0 ) {
@@ -307,7 +313,8 @@ export default class TabProxy extends Plugin {
307
313
title : duplicateTabTitle ,
308
314
icon,
309
315
tooltip : duplicateTabTooltip || duplicateTabTitle ,
310
- iconClass : getPathIcon ( duplicateTabName )
316
+ iconClass : getPathIcon ( duplicateTabName ) ,
317
+ show
311
318
}
312
319
}
313
320
}
@@ -321,7 +328,8 @@ export default class TabProxy extends Plugin {
321
328
title,
322
329
icon,
323
330
tooltip : description || title ,
324
- iconClass : getPathIcon ( name )
331
+ iconClass : getPathIcon ( name ) ,
332
+ show
325
333
} )
326
334
}
327
335
@@ -335,17 +343,29 @@ export default class TabProxy extends Plugin {
335
343
if ( ! this . loadedTabs . find ( tab => tab . name === name ) ) return // prevent removing tab that doesn't exist
336
344
this . loadedTabs = this . loadedTabs . filter ( ( tab , index ) => {
337
345
if ( ! previous && tab . name === name ) {
338
- if ( index - 1 >= 0 && this . loadedTabs [ index - 1 ] )
339
- previous = this . loadedTabs [ index - 1 ]
340
- else if ( index + 1 && this . loadedTabs [ index + 1 ] )
341
- previous = this . loadedTabs [ index + 1 ]
346
+ previous = this . getPreviousVisibleTab ( index )
347
+ if ( ! previous ) previous = this . getNextVisibleTab ( index )
342
348
}
343
349
return tab . name !== name
344
350
} )
345
351
this . renderComponent ( )
346
352
if ( previous ) this . switchTab ( previous . name )
347
353
}
348
354
355
+ getPreviousVisibleTab ( index ) {
356
+ for ( let i = index - 1 ; i >= 0 ; i -- ) {
357
+ if ( this . loadedTabs [ i ] . show ) return this . loadedTabs [ i ]
358
+ }
359
+ return null
360
+ }
361
+
362
+ getNextVisibleTab ( index ) {
363
+ for ( let i = index + 1 ; i < this . loadedTabs . length ; i ++ ) {
364
+ if ( this . loadedTabs [ i ] . show ) return this . loadedTabs [ i ]
365
+ }
366
+ return null
367
+ }
368
+
349
369
addHandler ( type , fn ) {
350
370
this . handlers [ type ] = fn
351
371
}
0 commit comments