summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2012-05-13 21:22:35 +0300
committerEli Zaretskii <eliz@gnu.org>2012-05-13 21:22:35 +0300
commitc8fb9dc689cdd9facc56d7220bdf3bb5864231f0 (patch)
tree76623f795a8a3c8714a60dfc621258600f760e12
parentac268e6786fbbb4eeb5b069b462bfb9c29272c67 (diff)
downloademacs-c8fb9dc689cdd9facc56d7220bdf3bb5864231f0.tar.gz
Fix bug #11464 with pos-visible-in-window-p and R2L text in L2R paragraph.
src/xdisp.c (pos_visible_p): Don't report a position visible when move_it_to stopped at the last line of window, which happens to be scanned backwards by the bidi iteration.
-rw-r--r--src/ChangeLog3
-rw-r--r--src/xdisp.c27
2 files changed, 29 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7352d8e0081..2f3643f4f80 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -14,6 +14,9 @@
proceed to consider_string_end without incrementing string
position. Don't increment display vector index past the end of
the display vector. (Bug#11417)
+ (pos_visible_p): Don't report a position visible when move_it_to
+ stopped at the last line of window, which happens to be scanned
+ backwards by the bidi iteration. (Bug#11464)
2012-05-11 Eli Zaretskii <eliz@gnu.org>
diff --git a/src/xdisp.c b/src/xdisp.c
index b1e2a925bce..a2c4589766d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1304,8 +1304,8 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
glyph. */
int top_x = it.current_x;
int top_y = it.current_y;
- enum it_method it_method = it.method;
/* Calling line_bottom_y may change it.method, it.position, etc. */
+ enum it_method it_method = it.method;
int bottom_y = (last_height = 0, line_bottom_y (&it));
int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w);
@@ -1313,6 +1313,31 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
visible_p = bottom_y > window_top_y;
else if (top_y < it.last_visible_y)
visible_p = 1;
+ if (bottom_y >= it.last_visible_y
+ && it.bidi_p && it.bidi_it.scan_dir == -1
+ && IT_CHARPOS (it) < charpos)
+ {
+ /* When the last line of the window is scanned backwards
+ under bidi iteration, we could be duped into thinking
+ that we have passed CHARPOS, when in fact move_it_to
+ simply stopped short of CHARPOS because it reached
+ last_visible_y. To see if that's what happened, we call
+ move_it_to again with a slightly larger vertical limit,
+ and see if it actually moved vertically; if it did, we
+ didn't really reach CHARPOS, which is beyond window end. */
+ struct it save_it = it;
+ /* Why 10? because we don't know how many canonical lines
+ will the height of the next line(s) be. So we guess. */
+ int ten_more_lines =
+ 10 * FRAME_LINE_HEIGHT (XFRAME (WINDOW_FRAME (w)));
+
+ move_it_to (&it, charpos, -1, bottom_y + ten_more_lines, -1,
+ MOVE_TO_POS | MOVE_TO_Y);
+ if (it.current_y > top_y)
+ visible_p = 0;
+
+ it = save_it;
+ }
if (visible_p)
{
if (it_method == GET_FROM_DISPLAY_VECTOR)