From 55a9298d63121578cd66ef7f14c14b2160aae77d Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 24 Jun 2017 14:29:32 +0300 Subject: [PATCH] Fix tab stops when line numbers are displayed * src/xdisp.c (x_produce_glyphs): * src/term.c (produce_glyphs): Adjust tab stops for the horizontal space taken by the line-number display. --- src/term.c | 4 ++++ src/xdisp.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/term.c b/src/term.c index 8770aff8a92..b0e7e052e51 100644 --- a/src/term.c +++ b/src/term.c @@ -1584,6 +1584,10 @@ produce_glyphs (struct it *it) { int absolute_x = (it->current_x + it->continuation_lines_width); + /* Adjust for line numbers. Kludge alert: the "2" below is + because we add 2 blanks to the actual line number. */ + if (!NILP (Vdisplay_line_numbers)) + absolute_x -= it->lnum_width + 2; int next_tab_x = (((1 + absolute_x + it->tab_width - 1) / it->tab_width) diff --git a/src/xdisp.c b/src/xdisp.c index f98e7a9ac7e..5f86f0bfde6 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -27865,6 +27865,10 @@ x_produce_glyphs (struct it *it) { int tab_width = it->tab_width * font->space_width; int x = it->current_x + it->continuation_lines_width; + /* Adjust for line numbers. Kludge alert: the "2" below + is because we add 2 blanks to the actual line number. */ + if (!NILP (Vdisplay_line_numbers)) + x -= (it->lnum_width + 2) * font->space_width; int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width; /* If the distance from the current position to the next tab -- 2.39.2