# HG changeset patch # User Chong Yidong # Date 1216230489 0 # Node ID c688688272588785a42515ba0243535019de9ef6 # Parent 05ebabb317e344ed319624a838dee8b596685674 (move_it_in_display_line): Account for word wrap, so that we don't move off the line. diff -r 05ebabb317e3 -r c68868827258 src/xdisp.c --- 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); }