aboutsummaryrefslogtreecommitdiff
path: root/helix-core
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-core
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-core')
-rw-r--r--helix-core/src/transaction.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 06efe259..f4f94b54 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -570,6 +570,11 @@ impl Transaction {
Self::from(changeset)
}
+ pub fn insert_at_eof(mut self, text: Tendril) -> Transaction {
+ self.changes.insert(text);
+ self
+ }
+
/// Generate a transaction with a change per selection range.
pub fn change_by_selection<F>(doc: &Rope, selection: &Selection, f: F) -> Self
where