summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2008-07-16 17:48:09 +0000
committerChong Yidong <cyd@stupidchicken.com>2008-07-16 17:48:09 +0000
commit8ee4117341797b62830c474838c376a3ca7d0a5e (patch)
tree167587ba169c7275901d8999c05ca4a5d658a38a /src/xdisp.c
parent01e19fea2a251cca6bfbd281932954fa0287edd0 (diff)
downloademacs-8ee4117341797b62830c474838c376a3ca7d0a5e.tar.gz
(move_it_in_display_line): Account for word wrap, so that we don't
move off the line.
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 43cfaee767b..d7b79b527cd 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -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);
}