mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
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:
parent
446f4efa65
commit
b28a18be73
2 changed files with 2 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue