From 5afc693af3eeb9bb8aba008e37be51186f00e9c6 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 9 Feb 2017 10:20:04 -0600 Subject: [PATCH] Reshuffle line numbering mode handling so we always directly refresh when the margin changes. The previous code only directly refreshed when the margin changed due to toggling line numbering mode on. When the margin changed due to toggling line numbering mode off, it would indirectly refresh via do_toggle(). --- src/nano.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/nano.c b/src/nano.c index e06458b..ec9f314 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1388,9 +1388,6 @@ void do_toggle(int flag) #ifndef DISABLE_COLOR case NO_COLOR_SYNTAX: #endif -#ifdef ENABLE_LINENUMBERS - case LINE_NUMBERS: -#endif case SOFTWRAP: refresh_needed = TRUE; break; @@ -2650,19 +2647,19 @@ int main(int argc, char **argv) int needed_margin = digits(openfile->filebot->lineno) + 1; /* Only enable line numbers when there is enough room for them. */ - if (ISSET(LINE_NUMBERS) && needed_margin < COLS - 3) { - if (needed_margin != margin) { - margin = needed_margin; - editwincols = COLS - margin; - /* The margin has changed -- schedule a full refresh. */ - refresh_needed = TRUE; - } - } else -#endif - { - margin = 0; - editwincols = COLS; + if (!ISSET(LINE_NUMBERS) || needed_margin >= COLS - 3) + needed_margin = 0; + + if (needed_margin != margin) { + margin = needed_margin; + editwincols = COLS - margin; + /* The margin has changed -- schedule a full refresh. */ + refresh_needed = TRUE; } +#else + margin = 0; + editwincols = COLS; +#endif /* ENABLE_LINENUMBERS */ if (currmenu != MMAIN) display_main_list(); -- 2.9.0