From 135b30efa7cbb067de8b81146c6d7ba6ee2a38c2 Mon Sep 17 00:00:00 2001 From: s0LA1337 Date: Tue, 21 Jun 2022 21:58:59 +0000 Subject: [PATCH 1/4] delete_backwards_char accepts any type of whitespace --- helix-term/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a07b51091b8c..1ee72eb5fdf7 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2981,7 +2981,7 @@ pub mod insert { for _ in 0..drop { // delete up to `drop` spaces match chars.next() { - Some(' ') => start -= 1, + Some(c) if c.is_whitespace() => start -= 1, _ => break, } } From c7f2643b381114d7d343ec7f3573ab7005ff8370 Mon Sep 17 00:00:00 2001 From: s0LA1337 Date: Mon, 27 Jun 2022 23:55:32 +0000 Subject: [PATCH 2/4] Fix inconsistency, where unicode whitespaces are treated as normal whitespaces --- helix-term/src/commands.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 1ee72eb5fdf7..c422870da125 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2944,7 +2944,7 @@ pub mod insert { let line_start_pos = text.line_to_char(range.cursor_line(text)); // consider to delete by indent level if all characters before `pos` are indent units. let fragment = Cow::from(text.slice(line_start_pos..pos)); - if !fragment.is_empty() && fragment.chars().all(|ch| ch.is_whitespace()) { + if !fragment.is_empty() && fragment.chars().all(|ch| ch.is_ascii_whitespace()) { if text.get_char(pos.saturating_sub(1)) == Some('\t') { // fast path, delete one char ( @@ -2981,7 +2981,7 @@ pub mod insert { for _ in 0..drop { // delete up to `drop` spaces match chars.next() { - Some(c) if c.is_whitespace() => start -= 1, + Some(c) if c.is_ascii_whitespace() => start -= 1, _ => break, } } From 2699601c226906d577d75100bd85d3bf12756355 Mon Sep 17 00:00:00 2001 From: s0LA1337 Date: Tue, 28 Jun 2022 00:23:04 +0000 Subject: [PATCH 3/4] Changed back to direct whitespace match --- helix-term/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index c422870da125..9670d4223351 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2981,7 +2981,7 @@ pub mod insert { for _ in 0..drop { // delete up to `drop` spaces match chars.next() { - Some(c) if c.is_ascii_whitespace() => start -= 1, + Some(' ') => start -= 1, _ => break, } } From 727a217d4edb520d6277792b905d6332d28dfb20 Mon Sep 17 00:00:00 2001 From: s0LA1337 Date: Thu, 30 Jun 2022 18:34:48 +0000 Subject: [PATCH 4/4] Only accept explicit whitespace / tabs --- helix-term/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 9670d4223351..097dc95ccdcd 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2944,7 +2944,7 @@ pub mod insert { let line_start_pos = text.line_to_char(range.cursor_line(text)); // consider to delete by indent level if all characters before `pos` are indent units. let fragment = Cow::from(text.slice(line_start_pos..pos)); - if !fragment.is_empty() && fragment.chars().all(|ch| ch.is_ascii_whitespace()) { + if !fragment.is_empty() && fragment.chars().all(|ch| ch == ' ' || ch == '\t') { if text.get_char(pos.saturating_sub(1)) == Some('\t') { // fast path, delete one char (