Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove conflicting keybindings added with selection feature #715

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/edit_mode/keybindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ pub fn add_common_navigation_bindings(kb: &mut Keybindings) {
KC::Home,
edit_bind(EC::MoveToLineStart { select: false }),
);
kb.add_binding(
KM::CONTROL,
KC::Char('a'),
edit_bind(EC::MoveToLineStart { select: false }),
);
kb.add_binding(
KM::NONE,
KC::End,
Expand Down Expand Up @@ -214,10 +209,18 @@ pub fn add_common_edit_bindings(kb: &mut Keybindings) {
// Base commands should not affect cut buffer
kb.add_binding(KM::CONTROL, KC::Char('h'), edit_bind(EC::Backspace));
kb.add_binding(KM::CONTROL, KC::Char('w'), edit_bind(EC::BackspaceWord));
kb.add_binding(KM::CONTROL, KC::Char('x'), edit_bind(EC::CutSelection));
kb.add_binding(KM::CONTROL, KC::Char('c'), edit_bind(EC::CopySelection));
kb.add_binding(
KM::CONTROL,
KM::CONTROL | KM::SHIFT,
KC::Char('x'),
edit_bind(EC::CutSelection),
);
kb.add_binding(
KM::CONTROL | KM::SHIFT,
KC::Char('c'),
edit_bind(EC::CopySelection),
);
kb.add_binding(
KM::CONTROL | KM::SHIFT,
Comment on lines +217 to +223
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not in conflict with any of the reedline default emacs-inspired bindings, most GUI terminal emulators that provide their own independent means of selection will intercept Ctrl-Shift-C and Ctrl-Shift-V.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your suggestion @sholderbach?

Here's my brief survey of the terminals I have installed on my mac. Some of them do selection, some won't. Some see ctrl-shift-anything as ctrl-anything according to keybindings listen. I think some could be made to work by disabling built-in ctrl-shift-anything.

Ghostty - works
Alacritty - works
iterm2 - does not work
wezterm - does not work
terminal.app - does not work
tabby - does not work
warp - does not work, selection doesn't even work
cool-retro-term - does not work, selection doesn't even work
kitty - does not work
rio - does not work
zed built-in terminal - does not work
vscode built-in terminal - does not work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of free keybinds which are part of the lowest common denominator accross the different terminals is certainly limited. Pretty likely that we would have to settle for something pretty unidiomatic/non-mnemonic if we want to squeeze it among everything people expect from bash readline/emacs. Maybe we would at some point add an additional editmode (that is not modal) to cover more GUI-like keybindings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to support a "pure" shell mode? Without emacs or vim bindings? I personally want to use nushell first and foremost as a shell. For my use case it would prioritise stuff like selection, history and stuff like that much higher than replicating terminal editor functionality.

Copy link
Collaborator

@fdncred fdncred Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds interesting. How would you do that?

KC::Char('v'),
edit_bind(EC::PasteCutBufferBefore),
);
Expand Down Expand Up @@ -268,5 +271,9 @@ pub fn add_common_selection_bindings(kb: &mut Keybindings) {
KC::Home,
edit_bind(EC::MoveToStart { select: true }),
);
kb.add_binding(KM::CONTROL, KC::Char('a'), edit_bind(EC::SelectAll));
kb.add_binding(
KM::CONTROL | KM::SHIFT,
KC::Char('a'),
edit_bind(EC::SelectAll),
);
}