From 3de025f8f441773a816165ce95f70da864a1c0e5 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Wed, 19 Aug 2009 05:38:07 +0000
Subject: [PATCH] 2009-08-19 Chris Allegretta <chrisa@asty.org> 	* Fix issue
 with soft wrapping not displaying the last character of each line, 	 
 fixed bug discovered by Hannes <mr_creosote@mutantwatch.de>.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 4 ++++
 src/winio.c | 8 ++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 04d85ce9..1fad54d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-19 Chris Allegretta <chrisa@asty.org>
+	* Fix issue with soft wrapping not displaying the last character of each line,
+	  fixed bug discovered by Hannes <mr_creosote@mutantwatch.de>.
+
 2009-08-17 Mike Frysinger <vapier@gentoo.org>
 	* doc/syntax/(gentoo|sh|tcl).nanorc: Fix problems with empty regexes on POSIX.
 	  Fixes Savannah bug 27175.
diff --git a/src/winio.c b/src/winio.c
index 6a9be893..ce73b997 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2440,11 +2440,11 @@ void reset_cursor(void)
 	openfile->current_y = 0;
 	filestruct *tmp;
 	for (tmp = openfile->edittop; tmp != openfile->current; tmp = tmp->next)
-	    openfile->current_y += 1 + strlenpt(tmp->data) / COLS;
+	    openfile->current_y += 1 + strlenpt(tmp->data) / (COLS - 1);
 
-	openfile->current_y += xplustabs() / COLS;
+	openfile->current_y += xplustabs() / (COLS - 1);
 	if (openfile->current_y < editwinrows)
-	    wmove(edit, openfile->current_y, xpt % COLS);
+	    wmove(edit, openfile->current_y, xpt % (COLS - 1));
     } else {
 	openfile->current_y = openfile->current->lineno -
 	    openfile->edittop->lineno;
@@ -2884,7 +2884,7 @@ int update_line(filestruct *fileptr, size_t index)
 	    mvwaddch(edit, line, COLS - 1, '$');
     } else {
         int full_length = strlenpt(fileptr->data);
-	for (index += COLS; index < full_length && line < editwinrows; index += COLS) {
+	for (index += COLS - 1; index < full_length && line < editwinrows; index += COLS - 1) {
 	    line++;
 #ifdef DEBUG
 	    fprintf(stderr, "update_line(): Softwrap code, moving to %d\n", line);
-- 
GitLab