AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 351 forks source link

Fixes #334: Make sure the cursor goes back to the begining of the lin… #335

Closed PierreBtz closed 3 years ago

PierreBtz commented 3 years ago

…e when jumping lines.

See #334 for the details. This code is doing the same as what Windows does.

There is something odd in the the n parameter passed to both methods is never used as we use 1. The Windows code does not do this and the previous code (changed in #309) did not do this either. I have a feeling it should be c.Down(n) and c.Up(n) but I did not analyze this library enough to be confident.

AlecAivazis commented 3 years ago

@coryb @mislav any chance you could test this out? I'm always nervous being the only set of eyes on something touching cursor interactions

nhatthm commented 3 years ago

Thanks @PierreBtz for the fix 🙌

I could reproduce the issue on my Mac (10.14.6 with iTerm2 3.4.5) and with hinshun/vt10x (see my test). It's fixed after applying your changes 👍

However, I don't have experience in Cursor and the test was in the emulator so I can't validate your code :D

Updated: I tested on Mac manually and it fixes the issue too!

AlecAivazis commented 3 years ago

@PierreBtz - i fixed the issue preventing the CI pipeline from executing. Mind rebasing onto master so we can get this in?

AlecAivazis commented 3 years ago

And thanks @nhatthm for verifying this fix!

PierreBtz commented 3 years ago

@AlecAivazis I rebased, looks like the build is passing now, thanks for fixing it, and thanks for your work on this project :)