nano

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

commit 8e779b6e858d8ac8263cf7b0bb760d422f1cf979
parent 3ab943c49ae32c3e04b6fae1507c51d8b3866995
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Sun, 13 Aug 2017 04:30:10 -0500

softwrap: properly update the viewport when adding text at firstcolumn

Adding text plus whitespace while the cursor is at or near the topleft
corner of the edit window can cause a change in the preceding chunk,
throwing firstcolumn out of alignment.  Catch this special case.

This fixes http://savannah.gnu.org/bugs/?51743.

Diffstat:
Msrc/nano.c | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -1855,6 +1855,15 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) if (openfile->mark_set && openfile->current == openfile->mark_begin && openfile->current_x < openfile->mark_begin_x) openfile->mark_begin_x += char_len; + + /* When the cursor is on the top row and not on the first chunk + * of a line, adding text there might change the preceding chunk + * and thus require an adjustment of firstcolumn. */ + if (openfile->current == openfile->edittop && + openfile->firstcolumn > 0) { + ensure_firstcolumn_is_aligned(); + refresh_needed = TRUE; + } #endif openfile->current_x += char_len;