From 25d4ebe30d7920bc087f004075048f62f53726af Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Mon, 20 Feb 2023 16:31:26 +0100 Subject: 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 --- helix-term/tests/test/commands.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'helix-term/tests/test/commands.rs') 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", + platform_line(indoc! {"\ + #[abc|]#ef + #(abc|)#f + #(abc|)# + #(abc|)# + "}) + .as_str(), + )) + .await?; + + Ok(()) +} -- cgit v1.2.3-70-g09d2