forked from fish-shell/fish-shell
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide old implementation of cancel-commandline as fallback
__fish_cancel_commandline was unused (even before) and has some issues on multiline commandlines. Make it use the previously active logic. Closes fish-shell#10935
- Loading branch information
Showing
5 changed files
with
35 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,4 @@ | ||
function __fish_setup_cancel_text -v fish_color_cancel -v fish_color_normal | ||
set -g __fish_cancel_text "^C" | ||
if set -q fish_color_cancel | ||
set __fish_cancel_text (echo -sn (set_color $fish_color_cancel) $__fish_cancel_text (set_color normal)) | ||
end | ||
if command -sq tput | ||
# Clear to EOL (to erase any autosuggestions) | ||
set __fish_cancel_text (echo -sn $__fish_cancel_text (tput el; or tput ce)) | ||
end | ||
end | ||
__fish_setup_cancel_text | ||
|
||
# This is meant to be bound to something like \cC. | ||
# This is meant to be bound to something like ctrl-c | ||
function __fish_cancel_commandline | ||
set -l cmd (commandline) | ||
if test -n "$cmd" | ||
echo -sn $__fish_cancel_text | ||
# `commandline -L` prints the line the cursor is on (starting from the prompt), so move the cursor | ||
# "to the end" then call `commandline -L` to get the total number of lines typed in at the prompt. | ||
commandline -C 10000000 | ||
printf (string repeat -n (commandline -L) "\n") | ||
commandline "" | ||
emit fish_cancel | ||
end | ||
|
||
# cancel: Close the pager if it's open (#4298) | ||
# repaint: Repaint even if we haven't cancelled anything so the prompt refreshes | ||
# and the terminal scrolls to it. | ||
commandline -f cancel -f repaint | ||
commandline -f cancel-commandline-traditional | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters