diff --git a/ChangeLog b/ChangeLog
index bc01ede1f76d488d0e071ddd820e56a7e32e2339..1375f1e3f5468a09415a7bde7e2efb48553a2472 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
 	* src/search.c (findnextstr): Poll the keyboard once per second.
 	* src/winio.c (reset_cursor): Remove a pointless condition, and make
 	use of an existing intermediary variable.
+	* src/winio.c (reset_cursor): Tidy up and rename a variable.
 
 2016-03-22  Thomas Rosenau  <thomasr@fantasymail.de>
 	* configure.ac, src/*.c: Check for the existence of the REG_ENHANCED
diff --git a/src/winio.c b/src/winio.c
index c18ac5373661994d94d0b762d0ea379326e7f42e..a257405caaadaa22d3685b6f7084f5f464f3fed0 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2270,28 +2270,30 @@ void onekey(const char *keystroke, const char *desc, size_t len)
     }
 }
 
-/* Reset current_y, based on the position of current, and put the cursor
- * in the edit window at (current_y, current_x). */
+/* Redetermine current_y from the position of current relative to edittop,
+ * and put the cursor in the edit window at (current_y, current_x). */
 void reset_cursor(void)
 {
     size_t xpt = xplustabs();
 
 #ifndef NANO_TINY
     if (ISSET(SOFTWRAP)) {
-	filestruct *tmp;
+	filestruct *line = openfile->edittop;
 	openfile->current_y = 0;
 
-	for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
-	    openfile->current_y += (strlenpt(tmp->data) / COLS) + 1;
-
+	while (line != NULL && line != openfile->current) {
+	    openfile->current_y += strlenpt(line->data) / COLS + 1;
+	    line = line->next;
+	}
 	openfile->current_y += xpt / COLS;
+
 	if (openfile->current_y < editwinrows)
 	    wmove(edit, openfile->current_y, xpt % COLS);
     } else
 #endif
     {
 	openfile->current_y = openfile->current->lineno -
-	    openfile->edittop->lineno;
+				openfile->edittop->lineno;
 
 	if (openfile->current_y < editwinrows)
 	    wmove(edit, openfile->current_y, xpt - get_page_start(xpt));