From: Chong Yidong Date: Wed, 16 Jul 2008 17:48:09 +0000 (+0000) Subject: (move_it_in_display_line): Account for word wrap, so that we don't X-Git-Tag: emacs-pretest-23.0.90~4129 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8ee4117341797b62830c474838c376a3ca7d0a5e;p=emacs.git (move_it_in_display_line): Account for word wrap, so that we don't move off the line. --- 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); }