veeso / termscp

🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3/SMB
https://termscp.veeso.dev
MIT License
1.61k stars 46 forks source link

[BUG] - Colours not reset after editor #94

Closed Pascal-So closed 2 years ago

Pascal-So commented 2 years ago

Description

When I open my editor (vim) which has a background colour set, the colours are not fully reset when switching back to the filetransfer view.

See this GIF with exaggerated colours for a demonstration:

colour

Steps to reproduce

  1. Set a .vimrc with a background colour that is noticeably different from your normal terminal background. Example .vimrc used for the gif:

    highlight Normal ctermbg=darkblue
  2. open termscp
  3. edit a file (make sure your editor is set to vim)
  4. close the editor (:q)
  5. enjoy

Expected behaviour

I'd expect the interface to retain the visuals from before I opened the editor.

Environment

Pascal-So commented 2 years ago

Same applies to when the editor is opened for adding an ssh key.

Pascal-So commented 2 years ago

The easy fix would be to just add this snippet after this line:

if let Some(ctx) = &mut self.context {
    ctx.terminal.clear_screen().ok();
}

plus of course to all the other relevant places.

The more elegant solution might be to create a wrapper for edit::edit_file but there we'd probably have to pass the TerminalBridge into this wrapper function because not all instances of edit::edit_file are called from within the same activity so there is no unified way to access the Context.

Pascal-So commented 2 years ago

Do you think the same issue also applies to view file (F3|V)? When I open a .txt file it just opens vim in a new window for me, can you think of any way where open::that would end up launching a program in the same terminal window?

veeso commented 2 years ago

Thanks for reporting. I put this issue on the 0.8.1 backlog.

No, I don't think this should apply to open::that since it should always start the app in a new window.

veeso commented 2 years ago

I wasn't able to reproduce this issue. The clear screen is performed as soon as you leave the text editor, so it should work. Maybe there was an issue with the order this action was performed (clear screen was before entering alternate screen). But it worked for me before too, so I really don't know.

Maybe this issue happens only on your terminal? What terminal are you using? You could try, if you want, to build the 0.8.1 branch and see if the problem persists.

Pascal-So commented 2 years ago

Okay after some confusion I realized that the bug only appeared when exiting vim with :q, I wasn't able to reproduce it with :wq????? (completely agree on the "sorcery" label)

Either way, the issue seems to be fixed, and the fix stems specifically from the 4b421a4a commit, not the dependency update before that. I'm using konsole 21.12.1 on KDE. Thanks for the fix!