Skip to content

Conversation

@akinomyoga
Copy link
Contributor

@akinomyoga akinomyoga commented Dec 28, 2023

With a single-line prompt, the last line of the output of the previous command is overwritten by the prompt rendered by enter_accept in Bash. I confirmed this behavior in all the terminals I tried, including xterm, lxterminal, terminology, terminator, mlterm, screen.

With the single-line prompt, tput cuu receives 0 as the parameter, but tput cuu 0 emits the control sequence \e[0A, which moves the cursor above by one line unexpectedly. This is because the parameter 0 for CUU means the default value, 1.

In this PR, to avoid moving the cursor when the prompt offset is 0, we check the offset value before running tput cuu.

@vercel
Copy link

vercel bot commented Dec 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
atuin-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 28, 2023 0:50am

With a single-line prompt, the last line of the output of the previous
command is overwritten by the prompt on the enter_accept.  In this
situation, `tput cuu` receives 0 as the argument, but `tput cuu 0`
emits the control sequence `\e[0A`, which moves the cursor above by
one line unexpectedly.  This is because the parameter 0 for CUU means
the default value, 1.  In this patch, to avoid moving the cursor when
the prompt offset is 0, we check the offset value before running `tput
cuu`.
Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Nice work on ble.sh too, btw 🙏

Seeing as this is your first time contributing, if you would like a holographic contributors-only Atuin sticker, then please fill out this form!

We do also have a Discord if you'd like to ask any questions, or just fancy hanging out!

@ellie ellie enabled auto-merge (squash) December 28, 2023 19:25
@ellie
Copy link
Member

ellie commented Dec 28, 2023

Failures are unrelated, clippy upgrade by the looks of it. will fix elsewhere, still OK to merge this

@ellie ellie disabled auto-merge December 28, 2023 19:34
@ellie ellie merged commit be1f6fd into atuinsh:main Dec 28, 2023
@akinomyoga akinomyoga deleted the fix-bash-cuu branch December 28, 2023 19:37
@akinomyoga
Copy link
Contributor Author

Thanks! I actually wanted to adjust the blesh-related code, but before that, I wanted to fix this existing issue. I'll submit the adjustments for ble.sh soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants