diff options
| author | Eli Zaretskii | 2014-08-18 18:34:49 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2014-08-18 18:34:49 +0300 |
| commit | 82193f227e98ab312c1cf7405691811eb357d6c1 (patch) | |
| tree | 11c4e9aa1251648e5c410b55cfc8563a870754dc /src | |
| parent | 27bc6b14650f947d72d015d0a25e2e8986eb83ad (diff) | |
| download | emacs-82193f227e98ab312c1cf7405691811eb357d6c1.tar.gz emacs-82193f227e98ab312c1cf7405691811eb357d6c1.zip | |
Fix bug #18276 with vertical motion through a display property.
src/indent.c (Fvertical_motion): Fix vertical motion up through a
display property after a newline.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/indent.c | 31 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8c89f693bca..3a2e03aa99c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-08-18 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * indent.c (Fvertical_motion): Fix vertical motion up through a | ||
| 4 | display property after a newline. (Bug#18276) | ||
| 5 | |||
| 1 | 2014-08-17 Eli Zaretskii <eliz@gnu.org> | 6 | 2014-08-17 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * xdisp.c (display_line): Don't assume that the call to | 8 | * xdisp.c (display_line): Don't assume that the call to |
diff --git a/src/indent.c b/src/indent.c index 711792f75cd..026f44ccf9c 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -2004,6 +2004,8 @@ whether or not it is currently displayed in some window. */) | |||
| 2004 | int first_x; | 2004 | int first_x; |
| 2005 | bool overshoot_handled = 0; | 2005 | bool overshoot_handled = 0; |
| 2006 | bool disp_string_at_start_p = 0; | 2006 | bool disp_string_at_start_p = 0; |
| 2007 | ptrdiff_t nlines = XINT (lines); | ||
| 2008 | int vpos_init = 0; | ||
| 2007 | 2009 | ||
| 2008 | itdata = bidi_shelve_cache (); | 2010 | itdata = bidi_shelve_cache (); |
| 2009 | SET_TEXT_POS (pt, PT, PT_BYTE); | 2011 | SET_TEXT_POS (pt, PT, PT_BYTE); |
| @@ -2093,18 +2095,31 @@ whether or not it is currently displayed in some window. */) | |||
| 2093 | 2095 | ||
| 2094 | overshoot_handled = 1; | 2096 | overshoot_handled = 1; |
| 2095 | } | 2097 | } |
| 2096 | if (XINT (lines) <= 0) | 2098 | else if (IT_CHARPOS (it) == PT - 1 |
| 2099 | && FETCH_BYTE (PT - 1) == '\n' | ||
| 2100 | && nlines < 0) | ||
| 2097 | { | 2101 | { |
| 2098 | it.vpos = 0; | 2102 | /* The position we started from was covered by a display |
| 2103 | property, so we moved to position before the string, and | ||
| 2104 | backed up one line, because the character at PT - 1 is a | ||
| 2105 | newline. So we need one less line to go up. */ | ||
| 2106 | nlines++; | ||
| 2107 | /* But we still need to record that one line, in order to | ||
| 2108 | return the correct value to the caller. */ | ||
| 2109 | vpos_init = -1; | ||
| 2110 | } | ||
| 2111 | if (nlines <= 0) | ||
| 2112 | { | ||
| 2113 | it.vpos = vpos_init; | ||
| 2099 | /* Do this even if LINES is 0, so that we move back to the | 2114 | /* Do this even if LINES is 0, so that we move back to the |
| 2100 | beginning of the current line as we ought. */ | 2115 | beginning of the current line as we ought. */ |
| 2101 | if (XINT (lines) == 0 || IT_CHARPOS (it) > 0) | 2116 | if (nlines == 0 || IT_CHARPOS (it) > 0) |
| 2102 | move_it_by_lines (&it, max (PTRDIFF_MIN, XINT (lines))); | 2117 | move_it_by_lines (&it, max (PTRDIFF_MIN, nlines)); |
| 2103 | } | 2118 | } |
| 2104 | else if (overshoot_handled) | 2119 | else if (overshoot_handled) |
| 2105 | { | 2120 | { |
| 2106 | it.vpos = 0; | 2121 | it.vpos = 0; |
| 2107 | move_it_by_lines (&it, min (PTRDIFF_MAX, XINT (lines))); | 2122 | move_it_by_lines (&it, min (PTRDIFF_MAX, nlines)); |
| 2108 | } | 2123 | } |
| 2109 | else | 2124 | else |
| 2110 | { | 2125 | { |
| @@ -2119,13 +2134,13 @@ whether or not it is currently displayed in some window. */) | |||
| 2119 | it.vpos = 0; | 2134 | it.vpos = 0; |
| 2120 | move_it_by_lines (&it, 1); | 2135 | move_it_by_lines (&it, 1); |
| 2121 | } | 2136 | } |
| 2122 | if (XINT (lines) > 1) | 2137 | if (nlines > 1) |
| 2123 | move_it_by_lines (&it, min (PTRDIFF_MAX, XINT (lines) - 1)); | 2138 | move_it_by_lines (&it, min (PTRDIFF_MAX, nlines - 1)); |
| 2124 | } | 2139 | } |
| 2125 | else | 2140 | else |
| 2126 | { | 2141 | { |
| 2127 | it.vpos = 0; | 2142 | it.vpos = 0; |
| 2128 | move_it_by_lines (&it, min (PTRDIFF_MAX, XINT (lines))); | 2143 | move_it_by_lines (&it, min (PTRDIFF_MAX, nlines)); |
| 2129 | } | 2144 | } |
| 2130 | } | 2145 | } |
| 2131 | 2146 | ||