GNU bug report logs - #30226
Fixing it->pixel_width / it->current_x when tabs and line numbers.

Previous Next

Package: emacs;

Reported by: Keith David Bershatsky <esq <at> lawlist.com>

Date: Tue, 23 Jan 2018 07:33:02 UTC

Severity: minor

Tags: wontfix

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Keith David Bershatsky <esq <at> lawlist.com>
To: Emacs Bug Reports <bug-gnu-emacs <at> gnu.org>
Subject: Fixing it->pixel_width / it->current_x when tabs and line numbers.
Date: Mon, 22 Jan 2018 23:32:14 -0800
[Message part 1 (text/plain, inline)]
The following snippet contains the ingredients that can be used to ultimately fix the problem described on the emacs-devel mailing list beginning at:

https://lists.gnu.org/archive/html/emacs-devel/2018-01/msg00466.html

In a nutshell, it->pixel_width and it->current_x are both incorrect in that situation.  Because the X is wrong, all subsequent references to it->current_x on the same line are also wrong.  In this snippet, we create a new gizmo in dispextern.h called my_pixel_width so as not to break anything while working on this issue.  Someone more knowledgeable than myself (e.g., Eli) will need to figure out what other adjustments in x_produce_glyphs are necessary so that it->pixel_width == it->my_pixel_width in this particular situation.  It is a little confusing, but here is what happens in this snippet:

it->pixel_width "should be" equal to it->my_pixel_width.  If we do that, however, then it->current_x will be wrong.

it->current_x "should be" equal to it->current_x less one (1) font->space_width.  Setting it->pixel_width to be one (1) font->space_width less than what it was fixes the value of it->current_x and does not break anything else in the process (as far as I can see).


dispextern.h:2590

  int my_pixel_width;


xdisp.c:28298

  if (it->char_to_display == '\t'
      && !NILP (Vdisplay_line_numbers)
      && it->w->hscroll > 0
      && it->current_x < it->lnum_pixel_width)
    {
      int my_tab_width = it->tab_width * font->space_width;
      int my_x = it->current_x + it->continuation_lines_width;
      int my_next_tab_x = ((1 + my_x + my_tab_width - 1) / my_tab_width)
                          * my_tab_width;
      if (my_next_tab_x - my_x < font->space_width)
        my_next_tab_x += my_tab_width;
      if (!NILP (Vdisplay_line_numbers))
        my_next_tab_x += it->lnum_pixel_width
                         - ((it->w->hscroll * font->space_width)
                            % my_tab_width);
      it->my_pixel_width = my_next_tab_x - it->lnum_pixel_width - font->space_width;
      it->pixel_width -= font->space_width;
    }
    else
      it->my_pixel_width = 0;

[patch.diff (application/diff, attachment)]

This bug report was last modified 127 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.