unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 28936@debbugs.gnu.org
Subject: bug#28936: nRe: bug#28936: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV before ZV
Date: Sun, 22 Oct 2017 12:22:26 -0700	[thread overview]
Message-ID: <m2r2tvgf7x.wl%esq@lawlist.com> (raw)
In-Reply-To: <m260b73mvx.wl%esq@lawlist.com>

The issue is observable at a distance of approximately up to five (5) text characters prior to ZV, rather than a distance of just one (1) it->pixel_width.  And, the issue is only present when word-wrap is non-nil.  In the example of a buffer containing only "Hello world!", the wrong result is observable on the letter "w", and on the letter "o", and on the letter "r" and on the letter "l", and on the letter "d", and on the exclamation point.  If my recollection is collect when trying out the example, the wrong result was also observable on the space between "hello" and "world".

The code that I borrowed is from xdisp.c at approximately 22680:  "while (it.current_x + it.pixel_width <= target_x".

I am running out the door for a few hours, and can try changing the while loop condition when I return -- however, I am fairly confident that copying the code at 22680 for this particular use case is what is needed.

Thanks,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [10-22-2017 11:30:45] <22 Oct 2017 21:30:45 +0300>
FROM:  Eli Zaretskii <eliz@gnu.org>
> 
> * * *
> 
> > With respect to `move_it_in_display_line`, I was not able to reliably land on `it.first_visible_x + lnum_pixel_width` when horizontal scrolling to the right AND text truncated on the left.  IT overshoots the target by one text character.
> 
> This means you have an off-by-one error, probably because you are
> not computing the target X coordinate correctly.  The mistake I show
> below is probably the same mistake you do elsewhere.
> 
> >   while (it->current_x + it->pixel_width <= target_x
> 
> This condition will cause the iterator to attempt to get to the
> character _after_ point, where it will hit ZV.  So what you see, viz.:
> 
> > STEP #5:  Observe that the result is "1" when it should be "2".
> 
> is expected.  You should change the condition to this:
> 
>    while (it->current_x < target_x





  parent reply	other threads:[~2017-10-22 19:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-22  3:02 bug#28936: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV before ZV Keith David Bershatsky
2017-10-22  5:14 ` Keith David Bershatsky
2017-10-22 14:12   ` Eli Zaretskii
2017-10-22 14:10 ` Eli Zaretskii
2017-10-22 18:05 ` Keith David Bershatsky
2017-10-22 18:30   ` Eli Zaretskii
2017-10-22 19:53   ` Eli Zaretskii
2017-10-22 19:22 ` Keith David Bershatsky [this message]
2017-10-22 19:41   ` bug#28936: nRe: " Eli Zaretskii
2017-10-23  5:20 ` Keith David Bershatsky
2017-10-23 13:55   ` Eli Zaretskii
2017-10-25  3:46 ` bug#28936: enhancement request: remove vertical scroll bar automatically when not needed Keith David Bershatsky
2017-10-25  5:30 ` Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2r2tvgf7x.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=28936@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).