@@ -186,7 +186,8 @@ export default class TabProxy extends Plugin {
186186 this . call ( 'manager' , 'deactivatePlugin' , name )
187187 } ,
188188 icon ,
189- description
189+ description ,
190+ show
190191 )
191192 show && this . switchTab ( name )
192193 }
@@ -210,6 +211,10 @@ export default class TabProxy extends Plugin {
210211
211212 focus ( name ) {
212213 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+ }
213218 this . tabsApi . activateTab ( name )
214219 }
215220
@@ -259,7 +264,7 @@ export default class TabProxy extends Plugin {
259264 * @param {string } description
260265 * @returns
261266 */
262- addTab ( name , title , switchTo , close , icon , description = '' ) {
267+ addTab ( name , title , switchTo , close , icon , description = '' , show = true ) {
263268 if ( this . _handlers [ name ] ) return this . renderComponent ( )
264269
265270 if ( ( name . endsWith ( '.vy' ) && icon === undefined ) || title . includes ( 'Vyper' ) ) {
@@ -290,7 +295,8 @@ export default class TabProxy extends Plugin {
290295 title,
291296 icon,
292297 tooltip : name ,
293- iconClass : getPathIcon ( name )
298+ iconClass : getPathIcon ( name ) ,
299+ show
294300 } )
295301 formatPath . shift ( )
296302 if ( formatPath . length > 0 ) {
@@ -307,7 +313,8 @@ export default class TabProxy extends Plugin {
307313 title : duplicateTabTitle ,
308314 icon,
309315 tooltip : duplicateTabTooltip || duplicateTabTitle ,
310- iconClass : getPathIcon ( duplicateTabName )
316+ iconClass : getPathIcon ( duplicateTabName ) ,
317+ show
311318 }
312319 }
313320 }
@@ -321,7 +328,8 @@ export default class TabProxy extends Plugin {
321328 title,
322329 icon,
323330 tooltip : description || title ,
324- iconClass : getPathIcon ( name )
331+ iconClass : getPathIcon ( name ) ,
332+ show
325333 } )
326334 }
327335
@@ -335,17 +343,29 @@ export default class TabProxy extends Plugin {
335343 if ( ! this . loadedTabs . find ( tab => tab . name === name ) ) return // prevent removing tab that doesn't exist
336344 this . loadedTabs = this . loadedTabs . filter ( ( tab , index ) => {
337345 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 )
342348 }
343349 return tab . name !== name
344350 } )
345351 this . renderComponent ( )
346352 if ( previous ) this . switchTab ( previous . name )
347353 }
348354
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+
349369 addHandler ( type , fn ) {
350370 this . handlers [ type ] = fn
351371 }
0 commit comments