1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-14 07:20:35 -08:00

Fix TAB display when the line-number face uses a smaller/larger font

* src/dispextern.h (struct it): New member lnum_pixel_width.
* src/xdisp.c (maybe_produce_line_number): Compute the width of
the line-number display in pixels.
(x_produce_glyphs): Use it->lnum_pixel_width instead of a kludge
that used it->lnum_width and made assumptions about pixel width.
This commit is contained in:
Eli Zaretskii 2017-06-30 11:43:49 +03:00
parent 5b9b49492b
commit dfe1c820d3
2 changed files with 8 additions and 6 deletions

View file

@ -2667,9 +2667,10 @@ struct it
/* The byte position corresponding to lnum. */
ptrdiff_t lnum_bytepos;
/* The width in columns needed for display of the line numbers, or
zero if not computed. */
/* The width, in columns and in pixels, needed for display of the
line numbers, or zero if not computed. */
int lnum_width;
int lnum_pixel_width;
/* The line number of point's line, or zero if not computed yet. */
ptrdiff_t pt_lnum;

View file

@ -20938,6 +20938,8 @@ maybe_produce_line_number (struct it *it)
}
}
/* Record the width in pixels we need for the line number display. */
it->lnum_pixel_width = tem_it.current_x;
/* Copy the produced glyphs into IT's glyph_row. */
struct glyph *g = scratch_glyph_row.glyphs[TEXT_AREA];
struct glyph *e = g + scratch_glyph_row.used[TEXT_AREA];
@ -27997,13 +27999,12 @@ x_produce_glyphs (struct it *it)
int tab_width = it->tab_width * font->space_width;
int x = it->current_x + it->continuation_lines_width;
int x0 = x;
/* Adjust for line numbers. Kludge alert: the "2" below
is because we add 2 blanks to the actual line number. */
/* Adjust for line numbers, if needed. */
if (!NILP (Vdisplay_line_numbers))
x -= (it->lnum_width + 2) * font->space_width;
x -= it->lnum_pixel_width;
int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
if (!NILP (Vdisplay_line_numbers))
next_tab_x += (it->lnum_width + 2) * font->space_width;
next_tab_x += it->lnum_pixel_width;
/* If the distance from the current position to the next tab
stop is less than a space character width, use the