GNU bug report logs -
#45837
28.0.50; incorrect cursor position in visual-line-mode when word-wrap-by-category is t
Previous Next
Reported by: Liu Hui <liuhui1610 <at> gmail.com>
Date: Wed, 13 Jan 2021 02:28:02 UTC
Severity: normal
Found in version 28.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #17 received at 45837 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> 于2021年1月14日周四 下午9:51写道:
>
> > From: Liu Hui <liuhui1610 <at> gmail.com>
> > Date: Thu, 14 Jan 2021 12:51:12 +0800
> > Cc: 45837 <at> debbugs.gnu.org
> >
> > BTW, in the case above, if the line wraps after a non-whitespace
> > character, C-k does not delete this character. How about the following
> > change to kill-visual-line?
>
> Yes, good catch. However, this is not entirely right, as the code you
> suggest should be _instead_ of skipping the whitespace that follows,
> not _in_addition_ to it (imagine that the line is wrapped at a
> non-whitespace character followed by whitespace). And while looking
> into adapting your patch to avoid removing more than the user
> intended, I found more issues with the existing code. So I'm
> proposing the patch below instead, which should correctly handle the
> following use cases:
>
> . visual line that ends in one or more whitespace characters, and the
> following visual line begins with one or more whitespace characters
> . visual line that ends with a non-whitespace character (under
> word-wrap-by-category) that is followed by one or more whitespace
> characters
> . line that is continued on the next visual line (visual-line-mode is
> off)
> . visual line that is wrapped in the middle of a display string or an
> overlay string with embedded whitespace characters
> . visual line that is wrapped in the middle of intangible text
>
> (The patch also fixes some minor issues with the documentation of this
> command.)
>
> WDYT?
>
I have tested the patch and found that the condition `(= (cdr (nth 2
(posn-at-point))) orig-y)` was sometimes too strict. `posn-at-point`
may give slightly different y positions for characters on the same
line when different fonts were used (examples can be found in the
HELLO file). If there are inline graphics (e.g. latex previews), the y
position can also be different.
My suggestion is `(< (abs (- (cdr (nth 2 (posn-at-point))) orig-y))
X)`, where X could be, empirically, `(/ (line-pixel-height) 3)` or
a customizable value.
The patch works well in other cases, thanks!
This bug report was last modified 4 years and 173 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.