Skip to content

Commit

Permalink
[status-] preserve longname after push() and quit()
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef committed Mar 1, 2024
1 parent aab3cda commit 3ce6f65
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions visidata/sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,10 @@ def push(vd, vs, pane=0, load=True):
'Push Sheet *vs* onto ``vd.sheets`` stack for *pane* (0 for active pane, -1 for inactive pane). Remove from other position if already on sheets stack.'
if not isinstance(vs, BaseSheet):
return # return instead of raise, some commands need this
if len(vd.sheets) > 0:
longname = vd.activeSheet.longname
else:
longname = None

if vs in vd.sheets:
vd.sheets.remove(vs)
Expand All @@ -1032,16 +1036,20 @@ def push(vd, vs, pane=0, load=True):

if load:
vs.ensureLoaded()
if longname:
vs.longname = longname


@VisiData.api
def quit(vd, *sheets):
'Remove *sheets* from sheets stack, asking for confirmation if needed.'

longname = vd.activeSheet.longname
for vs in sheets:
vs.confirmQuit('quit')
vs.pane = 0
vd.remove(vs)
vd.activeSheet.longname = longname


@BaseSheet.api
Expand Down

0 comments on commit 3ce6f65

Please sign in to comment.