From df2a4679d50801617069a3033232b03f52d9f661 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 31 Jan 2017 16:37:10 -0600
Subject: [PATCH] softwrap: account for softwrap in get_page_start()

In softwrap mode, nano doesn't horizontally scroll lines at all, so in
this case get_page_start() should always return zero.
---
 src/utils.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/utils.c b/src/utils.c
index d4da1a74..75a5919a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -367,13 +367,14 @@ char *free_and_assign(char *dest, char *src)
     return src;
 }
 
-/* nano scrolls horizontally within a line in chunks.  Return the column
- * number of the first character displayed in the edit window when the
+/* When not in softwrap mode, nano scrolls horizontally within a line in
+ * chunks (a bit smaller than the chunks used in softwrapping).  Return the
+ * column number of the first character displayed in the edit window when the
  * cursor is at the given column.  Note that (0 <= column -
  * get_page_start(column) < COLS). */
 size_t get_page_start(size_t column)
 {
-    if (column == 0 || column < editwincols - 1)
+    if (column < editwincols - 1 || ISSET(SOFTWRAP) || column == 0)
 	return 0;
     else if (editwincols > 8)
 	return column - 7 - (column - 7) % (editwincols - 8);
-- 
GitLab