PSFzf icon indicating copy to clipboard operation
PSFzf copied to clipboard

The shell prompt get offsets every time an item was accepted

Open nophDog opened this issue 3 years ago • 22 comments

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 : )

nophDog avatar Nov 28 '22 14:11 nophDog

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

mattcargile avatar Nov 28 '22 15:11 mattcargile

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.

nophDog avatar Nov 29 '22 07:11 nophDog

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?

mattcargile avatar Nov 29 '22 18:11 mattcargile

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

nophDog avatar Nov 30 '22 16:11 nophDog

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"?

mattcargile avatar Nov 30 '22 20:11 mattcargile

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.

nophDog avatar Dec 01 '22 07:12 nophDog

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.

mattcargile avatar Dec 01 '22 19:12 mattcargile

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.

nophDog avatar Dec 02 '22 09:12 nophDog