Simplify cursor movement for multi-line prompts before repainting

We have some key bindings that print directly to the terminal while the user
is still typing the command line. Thereafter, we redraw the command line,
so the user can resume typing. To redraw a multiline command line, we first
erase several lines above the cursor. To not erase the key bindings' output,
we move the cursor down that many lines.

Simplify the logic; no functional change.
This commit is contained in:
Johannes Altmanninger 2022-04-09 22:06:06 +02:00
parent 446f4efa65
commit b28a18be73
2 changed files with 2 additions and 15 deletions

View file

@ -15,12 +15,7 @@ function __fish_list_current_token -d "List contents of token under the cursor i
end
end
set -l line_count (count (fish_prompt))
if test $line_count -gt 1
for x in (seq 2 $line_count)
printf "\n"
end
end
string repeat \n --count=(math (count (fish_prompt)) - 1)
commandline -f repaint
end

View file

@ -28,15 +28,7 @@ function __fish_whatis_current_token -d "Show man page entries or function descr
printf "%s\n" $desc
set -l line_count (count (fish_prompt))
# Ensure line_count is greater than one to accomodate different
# versions of the `seq` command, some of which print the sequence in
# reverse order when the second argument is smaller than the first
if test $line_count -gt 1
for x in (seq 2 $line_count)
printf "\n"
end
end
string repeat \n --count=(math (count (fish_prompt)) - 1)
commandline -f repaint
end