kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
752 stars 35 forks source link

The shell prompt get offsets every time an item was accepted #202

Open nophDog opened 1 year ago

nophDog commented 1 year ago

psfzfIssue

It's happening months ago when I started to use PSFzf, I don't know what's going on behind the scene and it just didn't behave like expected, because when the prompt stays at the bottom of terminal, it got offset each time an item is accepted, looks weird.

I didn't see a related issue here. (If there was a disscussion, please let me know : )

mattcargile commented 1 year ago

I don't really think there is a fix for this. Every time you hit <ENTER> the prompt has to be redrawn and space for fzf output has to be allotted when you are at the bottom of the terminal. Maybe the redrawing of the prompt could be smarter though that seems complicated.

See the below function for the redrawn prompt. https://github.com/kelleyma49/PSFzf/blob/0364b14bbd5013a37348fe6681c4980195515ab2/PSFzf.Base.ps1#L122-L135

nophDog commented 1 year ago

Thanks for your explain and so we have to wait the official team of psreadline to fix :(

I don't really think there is a fix for this. Every time you hit <ENTER> the prompt has to be redrawn and space for fzf output has to be allotted when you are at the bottom of the terminal. Maybe the redrawing of the prompt could be smarter though that seems complicated.

mattcargile commented 1 year ago

Well maybe. You also have a two lined prompt which is different than mine. Are you using startship to draw your prompt or oh-my-posh? Additionally, what version and apps are you using below? It could be related to that. It looks like you are typing higher order Unicode characters too and it appears you are hitting ESC which causes the prompt to jump anyway and rewrite differently because of fzf when you are at the bottom of the terminal window.

Version PSReadline : Version of _PowerShell: Version and Terminal Application?

nophDog commented 1 year ago

Well maybe. You also have a two lined prompt which is different than mine.

I'm not sure if this made a difference so I tested again with command pwsh -noprofile version on both Windows Terminal and Hyper Terminal, here's the gif.

psfzfIssueInWT

(The Hyper Terminal gif is too big somehow, so I didn't upload it but it's almost the same result

Are you using startship to draw your prompt or oh-my-posh?

Yes, I am using starship for now, but it should not affect cause this time I used pwsh -noprofile to launch a subshell, right?

It looks like you are typing higher order Unicode characters too

I am a Chinese and '空格' means 'Space' key, that's probably not the problem


Version PSReadline : Version of _PowerShell: Version and Terminal Application?

Version PSReadline : 2.2.6 Version of _PowerShell: 7.3.0 Version and Terminal Application: 1.15.2875.0 Windows Version: Windows 11 Pro WorkStation OS Version: 22621.900

WindowsTerminal_yIxBVBNdWv

mattcargile commented 1 year ago

Looks like our version are matching well except I am Win 10 22H2 running single line oh-my-posh.

That gif looks like it is working like it should. No? Even your original gif didn't appear all that off. The problem is when your prompt gets to the bottom and has to "jump"?

nophDog commented 1 year ago

The problem is when your prompt gets to the bottom and has to "jump"?

Exactly, it won't work as expected when the prompt stays at the bottom of terminal.

mattcargile commented 1 year ago

Ah ok, so you don't want all that white space generating as you go in and out of fzf.

Hmm. I wonder if this module can hook into some class in PSReadline or the like and try to rewrite the prompt where it was instead of at the bottom? I don't know if that information is available.

nophDog commented 1 year ago

I wonder if this module can hook into some class in PSReadline or the like and try to rewrite the prompt where it was instead of at the bottom?

Sorry but I do know little about PowerShell and I am not a developer :(

Just let me know if you need help or else.