nano

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

commit d54180ad8bea9753b9cc388dee1bdaa6fefad09e
parent 065afe6e0f684945a5375751af15e23feebbf548
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 28 Apr 2019 12:02:38 +0200

tweaks: reduce a bit of mark-adjusting code to its essence

It doesn't matter whether the grafted text contains a newline or not.

It only matters whether the mark was before or after the cursor.  When
it was after the cursor, the mark needs to be set to the bottom line of
the grafted text and its x coordinate needs adjustment; and when it was
before the cursor, the mark just needs to be set to the top line of the
grafted text.

Diffstat:
Msrc/nano.c | 14++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -431,20 +431,14 @@ void ingraft_buffer(linestruct *somebuffer) openfile->current_x += current_x_save; #ifndef NANO_TINY - /* Refresh the mark's pointer, and compensate the mark's + /* When needed, refresh the mark's pointer and compensate the mark's * x coordinate for the change in the current line. */ if (openfile->mark && single_line) { - if (openfile->filetop == openfile->filebot) { - openfile->mark = openfile->current; - if (!right_side_up) - openfile->mark_x += openfile->current_x - current_x_save; + if (!right_side_up) { + openfile->mark = openfile->filebot; + openfile->mark_x += openfile->current_x - current_x_save; } else - if (right_side_up) openfile->mark = openfile->filetop; - else { - openfile->mark = openfile->current; - openfile->mark_x += openfile->current_x - current_x_save; - } } #endif