From 4d996e4c394c4d80aa6cab51cb62a880382ac293 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 20 Oct 2016 16:37:56 +0200
Subject: [PATCH] screen: suppress line numbers when the terminal is very
 narrow

To prevent the display from getting messed up, making nano unusable.
---
 src/winio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/winio.c b/src/winio.c
index 4330814b..73c367c0 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2269,10 +2269,12 @@ void edit_draw(filestruct *fileptr, const char *converted, int
     assert(strlenpt(converted) <= editwincols);
 
 #ifdef ENABLE_LINENUMBERS
-    if (ISSET(LINE_NUMBERS)) {
+    int needed_margin = digits(openfile->filebot->lineno) + 1;
+
+    if (ISSET(LINE_NUMBERS) && needed_margin < COLS - 3) {
 	/* If the line numbers now require more room, schedule a refresh. */
-	if (digits(openfile->filebot->lineno) + 1 != margin) {
-	    margin = digits(openfile->filebot->lineno) + 1;
+	if (needed_margin != margin) {
+	    margin = needed_margin;
 	    editwincols = COLS - margin;
 	    refresh_needed = TRUE;
 	}
-- 
GitLab