summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorGokul Soumya2021-07-28 16:03:05 +0000
committerIvan Tham2021-07-29 00:39:58 +0000
commit8a2fa692f26f5bff5861151f395304837f5d93ec (patch)
tree73c65b6c49a86f78438e68c5d6c16ad2b9c1de94 /helix-term/src/commands.rs
parentb90450b9e8b995e96a723a5d8c7b179ad2967c5a (diff)
Refactor case where key event is solely a character
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs36
1 files changed, 6 insertions, 30 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 42794d96..32eb3f00 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -3632,11 +3632,7 @@ fn wclose(cx: &mut Context) {
fn select_register(cx: &mut Context) {
cx.on_next_key(move |cx, event| {
- if let KeyEvent {
- code: KeyCode::Char(ch),
- ..
- } = event
- {
+ if let Some(ch) = event.char() {
cx.editor.selected_register.select(ch);
}
})
@@ -3687,11 +3683,7 @@ fn select_textobject_inner(cx: &mut Context) {
fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
let count = cx.count();
cx.on_next_key(move |cx, event| {
- if let KeyEvent {
- code: KeyCode::Char(ch),
- ..
- } = event
- {
+ if let Some(ch) = event.char() {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
@@ -3713,11 +3705,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
fn surround_add(cx: &mut Context) {
cx.on_next_key(move |cx, event| {
- if let KeyEvent {
- code: KeyCode::Char(ch),
- ..
- } = event
- {
+ if let Some(ch) = event.char() {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc.selection(view.id);
@@ -3743,17 +3731,9 @@ fn surround_add(cx: &mut Context) {
fn surround_replace(cx: &mut Context) {
let count = cx.count();
cx.on_next_key(move |cx, event| {
- if let KeyEvent {
- code: KeyCode::Char(from),
- ..
- } = event
- {
+ if let Some(from) = event.char() {
cx.on_next_key(move |cx, event| {
- if let KeyEvent {
- code: KeyCode::Char(to),
- ..
- } = event
- {
+ if let Some(to) = event.char() {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc.selection(view.id);
@@ -3783,11 +3763,7 @@ fn surround_replace(cx: &mut Context) {
fn surround_delete(cx: &mut Context) {
let count = cx.count();
cx.on_next_key(move |cx, event| {
- if let KeyEvent {
- code: KeyCode::Char(ch),
- ..
- } = event
- {
+ if let Some(ch) = event.char() {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc.selection(view.id);