Make new ctrl-c behavior "clear-commandline"
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run

And leave the old behavior under the name "cancel-commandline".

This renames "cancel-commandline-traditional" back to
"cancel-commandline", so the old name triggers the old behavior.

Fixes #10935
This commit is contained in:
Fabian Boehm 2025-01-14 19:58:26 +01:00
parent 021b18335c
commit 28233b0711
6 changed files with 12 additions and 8 deletions

View File

@ -170,6 +170,9 @@ The following special input functions are available:
``capitalize-word``
make the current word begin with a capital letter
``clear-commandline``
empty the entire commandline
``clear-screen``
clears the screen and redraws the prompt.

View File

@ -67,7 +67,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv alt-o __fish_preview_current_file
bind --preset $argv alt-w __fish_whatis_current_token
bind --preset $argv ctrl-l scrollback-push repaint
bind --preset $argv ctrl-c cancel-commandline
bind --preset $argv ctrl-c clear-commandline
bind --preset $argv ctrl-u backward-kill-line
bind --preset $argv ctrl-k kill-line
bind --preset $argv ctrl-w backward-kill-path-component

View File

@ -64,7 +64,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
# Default (command) mode
bind -s --preset :,q exit
bind -s --preset -m insert ctrl-c cancel-commandline repaint-mode
bind -s --preset -m insert ctrl-c clear-commandline repaint-mode
bind -s --preset -M default h backward-char
bind -s --preset -M default l forward-char
bind -s --preset -m insert enter execute

View File

@ -146,8 +146,8 @@ const INPUT_FUNCTION_METADATA: &[InputFunctionMetadata] = &[
make_md(L!("beginning-of-line"), ReadlineCmd::BeginningOfLine),
make_md(L!("cancel"), ReadlineCmd::Cancel),
make_md(L!("cancel-commandline"), ReadlineCmd::CancelCommandline),
make_md(L!("cancel-commandline-traditional"), ReadlineCmd::CancelCommandlineTraditional),
make_md(L!("capitalize-word"), ReadlineCmd::CapitalizeWord),
make_md(L!("clear-commandline"), ReadlineCmd::ClearCommandline),
make_md(L!("clear-screen"), ReadlineCmd::ClearScreenAndRepaint),
make_md(L!("complete"), ReadlineCmd::Complete),
make_md(L!("complete-and-search"), ReadlineCmd::CompleteAndSearch),

View File

@ -124,8 +124,8 @@ pub enum ReadlineCmd {
ExpandAbbr,
DeleteOrExit,
Exit,
ClearCommandline,
CancelCommandline,
CancelCommandlineTraditional,
Cancel,
Undo,
Redo,

View File

@ -2552,7 +2552,7 @@ impl<'a> Reader<'a> {
self.data
.update_buff_pos(EditableLineTag::Commandline, Some(self.command_line_len()));
}
rl::CancelCommandline | rl::CancelCommandlineTraditional => {
rl::CancelCommandline | rl::ClearCommandline => {
if self.conf.exit_on_interrupt {
self.parser
.set_last_statuses(Statuses::just(STATUS_CMD_ERROR.unwrap()));
@ -2562,10 +2562,11 @@ impl<'a> Reader<'a> {
if self.command_line.is_empty() {
return;
}
if c == rl::CancelCommandlineTraditional {
if c == rl::CancelCommandline {
// Move cursor to the end of the line.
let end = self.command_line.len();
self.update_buff_pos(EditableLineTag::Commandline, Some(end));
self.autosuggestion.clear();
// Repaint also changes the actual cursor position
if self.is_repaint_needed(None) {
@ -2589,7 +2590,7 @@ impl<'a> Reader<'a> {
EditableLineTag::Commandline,
Edit::new(0..self.command_line_len(), L!("").to_owned()),
);
if c == rl::CancelCommandlineTraditional {
if c == rl::CancelCommandline {
self.screen
.reset_abandoning_line(usize::try_from(termsize_last().width).unwrap());
}
@ -5426,7 +5427,7 @@ fn command_ends_paging(c: ReadlineCmd, focused_on_search_field: bool) -> bool {
| rl::AcceptAutosuggestion
| rl::DeleteOrExit
| rl::CancelCommandline
| rl::CancelCommandlineTraditional
| rl::ClearCommandline
| rl::Cancel =>
// These commands always end paging.
{