mirror of
https://github.com/atuinsh/atuin.git
synced 2024-12-26 17:09:14 +01:00
fix(bash): fix loss of the last output line with enter_accept (#1463)
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`.
This commit is contained in:
parent
d52e576129
commit
be1f6fd5ca
@ -29,8 +29,11 @@ __atuin_history() {
|
||||
then
|
||||
HISTORY=${HISTORY#__atuin_accept__:}
|
||||
# Reprint the prompt, accounting for multiple lines
|
||||
# shellcheck disable=SC2046
|
||||
tput cuu $(echo -n "${PS1@P}" | tr -cd '\n' | wc -c)
|
||||
local __atuin_prompt_offset
|
||||
__atuin_prompt_offset=$(echo -n "${PS1@P}" | tr -cd '\n' | wc -c)
|
||||
if ((__atuin_prompt_offset > 0)); then
|
||||
tput cuu "$__atuin_prompt_offset"
|
||||
fi
|
||||
echo "${PS1@P}$HISTORY"
|
||||
|
||||
if [[ -n "${BLE_VERSION-}" ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user