diff --git a/src/global.c b/src/global.c
index e804b23cbff0bdd943a6b0c7fcab0580db76987d..77c8d8420955f4c34dc87ef42af09fefdef81e79 100644
--- a/src/global.c
+++ b/src/global.c
@@ -49,12 +49,6 @@ int margin = 0;
 	/* The amount of space reserved at the left for line numbers. */
 int editwincols = -1;
 	/* The number of usable columns in the edit window: COLS - margin. */
-#ifdef ENABLE_LINENUMBERS
-int last_drawn_line = 0;
-        /* The line number of the last drawn line. */
-int last_line_y;
-        /* The y coordinate of the last drawn line. */
-#endif
 
 message_type lastmessage = HUSH;
 	/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
diff --git a/src/proto.h b/src/proto.h
index 9ef4cfc3ab199a663f951fc56ea7f847445b8ead..7dd423ebf296d099ebe9a6044ace4b3b365b7d07 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -40,10 +40,6 @@ extern bool focusing;
 
 extern int margin;
 extern int editwincols;
-#ifdef ENABLE_LINENUMBERS
-extern int last_drawn_line;
-extern int last_line_y;
-#endif
 
 extern message_type lastmessage;
 
diff --git a/src/winio.c b/src/winio.c
index 0d3800739eed4ed9b44e148991490de4df43abf5..1438c6228e7fcc9055a427a98f54412563d3766f 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2322,10 +2322,12 @@ void edit_draw(filestruct *fileptr, const char *converted, int
      * the text -- but only for the parts that are not softwrapped. */
     if (margin > 0) {
 	wattron(edit, interface_color_pair[LINE_NUMBER]);
-	if (last_drawn_line != fileptr->lineno || last_line_y >= line)
-	    mvwprintw(edit, line, 0, "%*ld", margin - 1, (long)fileptr->lineno);
-	else
+#ifndef NANO_TINY
+	if (ISSET(SOFTWRAP) && (startpos / editwincols > 0))
 	    mvwprintw(edit, line, 0, "%*s", margin - 1, " ");
+	else
+#endif
+	    mvwprintw(edit, line, 0, "%*ld", margin - 1, (long)fileptr->lineno);
 	wattroff(edit, interface_color_pair[LINE_NUMBER]);
     }
 #endif
@@ -2693,10 +2695,6 @@ void edit_draw(filestruct *fileptr, const char *converted, int
 	}
     }
 #endif /* !NANO_TINY */
-#ifdef ENABLE_LINENUMBERS
-    last_drawn_line = fileptr->lineno;
-    last_line_y = line;
-#endif
 }
 
 /* Just update one line in the edit buffer.  This is basically a wrapper