Skip to content

Commit b0b8a0a

Browse files
arkus7ogoffart
authored andcommitted
Add DeleteToStartOfLine text shortcut for Cmd + Backspace key on macOS
Introduced a new text shortcut, `DeleteToStartOfLine`, to allow users to delete text from the cursor position to the start of the line when the Cmd + Backspace key is pressed on macOS.
1 parent a857fe6 commit b0b8a0a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

internal/core/input.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ impl KeyEvent {
415415
key_codes::DownArrow => {
416416
return Some(TextShortcut::Move(TextCursorDirection::EndOfText))
417417
}
418+
key_codes::Backspace => {
419+
return Some(TextShortcut::DeleteToStartOfLine);
420+
}
418421
_ => (),
419422
};
420423
}
@@ -467,6 +470,8 @@ pub enum TextShortcut {
467470
DeleteWordForward,
468471
/// Delete the word to the left of the cursor (aka Ctrl + Backspace).
469472
DeleteWordBackward,
473+
/// Delete to the left of the cursor until the start of the line
474+
DeleteToStartOfLine,
470475
}
471476

472477
/// Represents how an item's key_event handler dealt with a key event.

internal/core/items/text.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,15 @@ impl Item for TextInput {
776776
);
777777
return KeyEventResult::EventAccepted;
778778
}
779+
TextShortcut::DeleteToStartOfLine => {
780+
TextInput::select_and_delete(
781+
self,
782+
TextCursorDirection::StartOfLine,
783+
window_adapter,
784+
self_rc,
785+
);
786+
return KeyEventResult::EventAccepted;
787+
}
779788
},
780789
Some(_) => {
781790
return KeyEventResult::EventIgnored;

0 commit comments

Comments
 (0)