changeset 96744:c68868827258

(move_it_in_display_line): Account for word wrap, so that we don't move off the line.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 16 Jul 2008 17:48:09 +0000
parents 05ebabb317e3
children d88ca977bf31
files src/xdisp.c
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Wed Jul 16 17:48:00 2008 +0000
+++ b/src/xdisp.c	Wed Jul 16 17:48:09 2008 +0000
@@ -7064,7 +7064,25 @@
 			 EMACS_INT to_charpos, int to_x,
 			 enum move_operation_enum op)
 {
-  move_it_in_display_line_to (it, to_charpos, to_x, op);
+  if (it->line_wrap == WORD_WRAP
+      && (op & MOVE_TO_X))
+    {
+      struct it save_it = *it;
+      int skip = move_it_in_display_line_to (it, to_charpos, to_x, op);
+      /* When word-wrap is on, TO_X may lie past the end
+	 of a wrapped line.  Then it->current is the
+	 character on the next line, so backtrack to the
+	 space before the wrap point.  */
+      if (skip == MOVE_LINE_CONTINUED)
+	{
+	  int prev_x = max (it->current_x - 1, 0);
+	  *it = save_it;
+	  move_it_in_display_line_to
+	    (it, -1, prev_x, MOVE_TO_X);
+	}
+    }
+  else
+    move_it_in_display_line_to (it, to_charpos, to_x, op);
 }