nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit e21ce0db1fbfdb25dd5c55aaabcb40dc8ff8a67a
parent e6429e782a09092eb87305d5d4cd2831c7129ad7
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun,  2 Sep 2018 13:26:12 +0200

cutting: when deleting whole words, don't join lines unexpectedly

That is, wait with deleting words until they start under cursor,
so the user can see which word is goin to be eaten, and join lines
only when the cursor already sits at the edge of a line.

Diffstat:
Msrc/text.c | 22+++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -205,11 +205,27 @@ void do_cutword(bool backward) cutbuffer = NULL; cutbottom = NULL; - /* Move the cursor to a word start, to the left or to the right. */ - if (backward) + /* Move the cursor to a word start, to the left or to the right. + * If that word is on another line and the cursor was not already + * on the edge of the original line, then put the cursor on that + * edge instead, so that lines will not be joined unexpectedly. */ + if (backward) { do_prev_word(ISSET(WORD_BOUNDS), FALSE); - else + if (openfile->current != is_current) { + if (is_current_x > 0) { + openfile->current = is_current; + openfile->current_x = 0; + } else + openfile->current_x = strlen(openfile->current->data); + } + } else { do_next_word(FALSE, ISSET(WORD_BOUNDS), FALSE); + if (openfile->current != is_current && + is_current->data[is_current_x] != '\0') { + openfile->current = is_current; + openfile->current_x = strlen(is_current->data); + } + } /* Set the mark at the start of that word. */ openfile->mark = openfile->current;