numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
721 stars 24 forks source link

Terminal output shifted left after opening an existing FTerm instance #80

Closed brettmitchelldev closed 8 months ago

brettmitchelldev commented 1 year ago

First of all, I love your plugin! As I'm sure others have done, I use it to wrap lf as a built-in file browser. It forms what I think is the most ergonomic part of my setup, and the API you've put together basically made it so I didn't even need to think about the terminal side of things. :rocket:

The issue I'm running into is that when I toggle the FTerm instance that contains my lf process and then open it back up again, the existing output re-appears shifted to the left by several characters part of the time.

This only appears to happen when the output produced by lf is wider than the window size defined by FTerm. This is almost certainly something I can fix on the lf side of things (seems to be caused by my file preview script, and only happens when I'm currently previewing a file that is wider than some threshold).

I wonder, though, if it makes sense to have FTerm scroll back to the left of the terminal output when restoring the terminal buffer's contents so that the left edge of the output is always visible?

numToStr commented 1 year ago

Would you mind posting a screen record to help me visualize the issue?

That being said, I don't think there is any API which we can use use to scroll the terminal.

brettmitchelldev commented 8 months ago

@numToStr Sorry for the long delay. I think I'm going to close this. As best as I can tell, it's specific to my configuration's integration with lf.

FWIW, I was able solve this by merely 0-ing the terminal buffer's horizontal scroll on the BufWinEnter event.

vim.api.nvim_input('<C-\\><C-n>0i')