aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-03-08 12:54:43 +0200
committerEli Zaretskii2014-03-08 12:54:43 +0200
commit2c65ad215a5459a4d5bbb9f35627a51dcbe3ae55 (patch)
treee2e718dc3a471bb9ff5d30ff9ced205845a6b583 /src
parent543d692e4f6fae0ba1352bab68f3f4139d829f0f (diff)
downloademacs-2c65ad215a5459a4d5bbb9f35627a51dcbe3ae55.tar.gz
emacs-2c65ad215a5459a4d5bbb9f35627a51dcbe3ae55.zip
Fix more failures of visual-order cursor movement under word-wrap (bug#16961).
src/xdisp.c (move_it_in_display_line_to): If word-wrap is ON, and there's a valid wrap point in the display line, the last glyph cannot "just barely fit" on this row, because display_line doesn't let it. Instead, proceed as if the last glyph didn't fit, so that we eventually back up the iterator to the wrap point. This avoids delusional behavior of move_it_to, whereby it proceeds to the next display line, but sets current_x to zero for all the glyphs that without word-wrap would fit on the previous display line. One result was that visual-order cursor movement behaved erratically under word-wrap. (Fmove_point_visually): Add code to find the x coordinate of the last character before wrap point, under word-wrap on a TTY.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog15
-rw-r--r--src/xdisp.c28
2 files changed, 42 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a63995129cd..18f412362f1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
12014-03-08 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (move_it_in_display_line_to): If word-wrap is ON, and
4 there's a valid wrap point in the display line, the last glyph
5 cannot "just barely fit" on this row, because display_line doesn't
6 let it. Instead, proceed as if the last glyph didn't fit, so that
7 we eventually back up the iterator to the wrap point. This avoids
8 delusional behavior of move_it_to, whereby it proceeds to the next
9 display line, but sets current_x to zero for all the glyphs that
10 without word-wrap would fit on the previous display line. One
11 result was that visual-order cursor movement behaved erratically
12 under word-wrap.
13 (Fmove_point_visually): Add code to find the x coordinate of the
14 last character before wrap point, under word-wrap on a TTY.
15
12014-03-07 Eli Zaretskii <eliz@gnu.org> 162014-03-07 Eli Zaretskii <eliz@gnu.org>
2 17
3 * xdisp.c (Fmove_point_visually): When under word-wrap, accept 18 * xdisp.c (Fmove_point_visually): When under word-wrap, accept
diff --git a/src/xdisp.c b/src/xdisp.c
index 1513d4a9a87..62915438e50 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8651,7 +8651,12 @@ move_it_in_display_line_to (struct it *it,
8651 doesn't fit on the line, e.g. a wide image. */ 8651 doesn't fit on the line, e.g. a wide image. */
8652 it->hpos == 0 8652 it->hpos == 0
8653 || (new_x == it->last_visible_x 8653 || (new_x == it->last_visible_x
8654 && FRAME_WINDOW_P (it->f))) 8654 && FRAME_WINDOW_P (it->f)
8655 /* When word-wrap is ON and we have a valid
8656 wrap point, we don't allow the last glyph
8657 to "just barely fit" on the line. */
8658 && (it->line_wrap != WORD_WRAP
8659 || wrap_it.sp < 0)))
8655 { 8660 {
8656 ++it->hpos; 8661 ++it->hpos;
8657 it->current_x = new_x; 8662 it->current_x = new_x;
@@ -20857,6 +20862,27 @@ Value is the new character position of point. */)
20857 move_it_by_lines (&it, -1); 20862 move_it_by_lines (&it, -1);
20858 target_x = it.last_visible_x - !FRAME_WINDOW_P (it.f); 20863 target_x = it.last_visible_x - !FRAME_WINDOW_P (it.f);
20859 target_is_eol_p = true; 20864 target_is_eol_p = true;
20865 /* Under word-wrap, we don't know the x coordinate of
20866 the last character displayed on the previous line,
20867 which immediately precedes the wrap point. To find
20868 out its x coordinate, we try moving to the right
20869 margin of the window, which will stop at the wrap
20870 point, and then reset target_x to point at the
20871 character that precedes the wrap point. This is not
20872 needed on GUI frames, because (see below) there we
20873 move from the left margin one grapheme cluster at a
20874 time, and stop when we hit the wrap point. */
20875 if (!FRAME_WINDOW_P (it.f) && it.line_wrap == WORD_WRAP)
20876 {
20877 void *it_data = NULL;
20878 struct it it2;
20879
20880 SAVE_IT (it2, it, it_data);
20881 move_it_in_display_line_to (&it, ZV, target_x,
20882 MOVE_TO_POS | MOVE_TO_X);
20883 target_x = it.current_x - 1;
20884 RESTORE_IT (&it, &it2, it_data);
20885 }
20860 } 20886 }
20861 } 20887 }
20862 else 20888 else