CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

🐞 Terminal State is not saved when switching tabs

Open bombardier200 opened this issue 3 years ago • 13 comments

Description

When you switch tabs on status bar, and then go back to the terminal, it will be refreshed.

To Reproduce

  1. Expand the status bar to see the terminal.
  2. Enter a command in the terminal
  3. Select a different tab in the status bar
  4. Select the terminal tab

Expected behavior

The terminal should keep its state and should not be a fresh screen when you select the tab again.

Version information

CodeEdit: 0.0.1 build 7 macOS: 13.1

Additional context

https://user-images.githubusercontent.com/25121427/211723143-e6d8f7c1-17ea-4131-9e60-b79d021b0313.mov

bombardier200 avatar Jan 11 '23 05:01 bombardier200

Might be related to #917 and @Code-DJ's PR #984

austincondiff avatar Feb 16 '23 22:02 austincondiff

I've looked into this and it seems that it's a SwiftTerm bug.

iggy890 avatar Mar 07 '23 06:03 iggy890

@iggy890 what exactly brings you to this conclusion?

lukepistrol avatar Mar 07 '23 07:03 lukepistrol

@lukepistrol That's because whenever the tabs are switched the updateNSView() function is fired it saves the terminal state. But SwiftTerm doesn't save the state, if you want to I could create an issue and tag the developer.

iggy890 avatar Mar 07 '23 14:03 iggy890

@iggy890 SwiftTerm is not supposed to save anything. The problem lies in somewhere in our implementation because at some point the SwiftTerm view gets deallocated (released from memory) and then reallocated while the saved state is not applied for some reason. Nothing to do with SwiftTerm.

lukepistrol avatar Mar 07 '23 14:03 lukepistrol

Yeah I am going to take a look at this and see why the saved state does not get added to the new view, I have done some experimenting and I think I can find a solution.

bombardier200 avatar Mar 07 '23 14:03 bombardier200

On the latest release (0.0.2-alpha.27) this cannot be reproduced anyway. Can someone please double-check?

https://user-images.githubusercontent.com/9460130/223475428-bb2d9fbe-9650-4e8d-b4ff-e7990dc6fd89.mov

lukepistrol avatar Mar 07 '23 15:03 lukepistrol

My terminal still does not save

bombardier200 avatar Mar 07 '23 16:03 bombardier200

@lukepistrol what is your terminal type? maybe a specific type of terminal does not save?

bombardier200 avatar Mar 07 '23 16:03 bombardier200

@bombardier200 ZSH

lukepistrol avatar Mar 07 '23 16:03 lukepistrol

@lukepistrol This issue also happens with me and my terminal type is ZSH

iggy890 avatar Mar 07 '23 16:03 iggy890

@luah5 What do you mean by the tabs are the same?

austincondiff avatar Jul 04 '23 03:07 austincondiff

Seems to me there's two problems.

UtilityAreaTerminalView.swift:247

.onAppear(perform: initializeTerminals)

is reinitializing terminals every time the view loads and should be changed to something like

.onAppear { if model.terminals.isEmpty { initializeTerminals() } }

With this change, any terminal views you have open will be restored with env variables intact, but, seemingly unrelatedly, the buffer will be reset to a fresh prompt without previous commands and output, like pressing ⌘K. I investigated this for an embarrassingly long time and don't understand why that's happening.

gdbing avatar Apr 01 '24 19:04 gdbing