aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests/test/commands.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-02-20 15:31:26 +0000
committerBlaž Hrastnik2023-05-18 06:20:55 +0000
commit25d4ebe30d7920bc087f004075048f62f53726af (patch)
tree2b47474079965eb42d7b3b0bb8455f14a03dcacb /helix-term/tests/test/commands.rs
parent2c3ccc3e8b2487e9bcca271341aabc67811ebb46 (diff)
don't move cursor while forward deleting in append mode
Currently, when forward deleting (`delete_char_forward` bound to `del`, `delete_word_forward`, `kill_to_line_end`) the cursor is moved to the left in append mode (or generally when the cursor is at the end of the selection). For example in a document `|abc|def` (|indicates selection) if enter append mode the cursor is moved to `c` and the selection becomes: `|abcd|ef`. When deleting forward (`del`) `d` is deleted. The expectation would be that the selection doesn't shrink so that `del` again deletes `e` and then `f`. This would look as follows: `|abcd|ef` `|abce|f` `|abcf|` `|abc |` This is inline with how other editors like kakoune work. However, helix currently moves the selection backwards leading to the following behavior: `|abcd|ef` `|abc|ef` `|ab|ef` `ef` This means that `delete_char_forward` essentially acts like `delete_char_backward` after deleting the first character in append mode. To fix the problem the cursor must be moved to the right while deleting forward (first fix in this commit). Furthermore, when the EOF char is reached a newline char must be inserted (just like when entering appendmode) to prevent the cursor from moving to the right
Diffstat (limited to 'helix-term/tests/test/commands.rs')
-rw-r--r--helix-term/tests/test/commands.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs
index 1efb204e..f91a6371 100644
--- a/helix-term/tests/test/commands.rs
+++ b/helix-term/tests/test/commands.rs
@@ -429,3 +429,26 @@ async fn test_delete_word_forward() -> anyhow::Result<()> {
Ok(())
}
+#[tokio::test(flavor = "multi_thread")]
+async fn test_delete_char_forward() -> anyhow::Result<()> {
+ test((
+ platform_line(indoc! {"\
+ #[abc|]#def
+ #(abc|)#ef
+ #(abc|)#f
+ #(abc|)#
+ "})
+ .as_str(),
+ "a<del><esc>",
+ platform_line(indoc! {"\
+ #[abc|]#ef
+ #(abc|)#f
+ #(abc|)#
+ #(abc|)#
+ "})
+ .as_str(),
+ ))
+ .await?;
+
+ Ok(())
+}