emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange display behavior after filling


From: Kim F. Storm
Subject: Re: Strange display behavior after filling
Date: Tue, 18 Apr 2006 13:57:46 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

YAMAMOTO Mitsuharu <address@hidden> writes:

> I found some strange display behavior after filling.  In the
> following, "row" means a displayed horizontal segment, and "line"
> means a sequence of characters delimited by newlines.
>
>   1. emacs -D -Q
>   2. M-q  (I'm not sure why this is needed.)
>   3. Insert "123456789 " (without quotations or newlines) 18 times.
>      Say, C-x ( 1 2 3 4 5 6 7 8 9 SPC C-x ) C-u 1 7 C-x e.
>      It is displayed in three rows.
>   4. M-<
>   5. C-u 1 C-v
>
> Now the first row becomes continued to both directions.
>
>   6. M-q
>
> Then the first row is displayed shorter than the second one, whereas
> they have the same number of characters.
>
>   7. C-p C-n C-n
>
> The line number in the mode line says the cursor is at the third line.
> But it is displayed at the second row that corresponds to the second
> line.

The problem starts when the C-u 1 C-v scrolling command moves window
start to a position which happens to be in the middle of a
continuation line.

Now, when the filling command has reformatted the buffer text, the
redisplay code still starts window display at the old window start --
which still is in the middle of a line, but not at the same relative
position in the line as before ... so it gets confused.

This is just one way in which a buffer change can mess things up when
window start is not at the start of a line, so I think it is generally
a bit difficult to find a method which will always select the
intuitively best window start after such a change.

On the other hand, I guess this is not something which happens very
often, so a simpler method is probably ok.  Below is a change which
simply will just recenter the display in this case.

Please test if this gives good results, or if it has some bad effects
on existing features....

2006-04-18  Kim F. Storm  <address@hidden>

        * xdisp.c (try_window_id): If first window line is a continuation line,
        and the first change is before window start, return -1 to select a new
        window start.

*** xdisp.c     16 Apr 2006 23:05:20 +0200      1.1086
--- xdisp.c     18 Apr 2006 13:53:04 +0200      
***************
*** 14263,14269 ****
       but why that was tested escapes me at the moment.  */
    if (CHARPOS (start) >= first_changed_charpos
        && CHARPOS (start) <= last_changed_charpos)
!     GIVE_UP (15);
  
    /* Check that window start agrees with the start of the first glyph
       row in its current matrix.  Check this after we know the window
--- 14263,14278 ----
       but why that was tested escapes me at the moment.  */
    if (CHARPOS (start) >= first_changed_charpos
        && CHARPOS (start) <= last_changed_charpos)
!     {
!       /* If first window line is a continuation line, and the first
!        change is before window start, return -1 to select a new
!        window start.*/
!       if (NILP (w->start_at_line_beg)
!         && CHARPOS (start) > first_changed_charpos)
!       return -1;
! 
!       GIVE_UP (15);
!     }
  
    /* Check that window start agrees with the start of the first glyph
       row in its current matrix.  Check this after we know the window

-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]