]> git.eshelyaron.com Git - emacs.git/commitdiff
(move_it_in_display_line): Account for word wrap, so that we don't
authorChong Yidong <cyd@stupidchicken.com>
Wed, 16 Jul 2008 17:48:09 +0000 (17:48 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Wed, 16 Jul 2008 17:48:09 +0000 (17:48 +0000)
move off the line.

src/xdisp.c

index 43cfaee767bb02d02fbfd8c9cc2e773008d4a05f..d7b79b527cd5ffd04a695fcdd16a21f807853c87 100644 (file)
@@ -7064,7 +7064,25 @@ move_it_in_display_line (struct it *it,
                         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);
 }