diff options
| author | Eli Zaretskii | 2015-09-13 13:15:55 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2015-09-13 13:15:55 +0300 |
| commit | 6514b30e6eb14e9d2364c08526dc8440a7412fef (patch) | |
| tree | f6a1f9970c8cfdf786f25e682da4ccabfa956e60 /src | |
| parent | fc9dc032906d840f63d29fbdcfd25e36ca3451b8 (diff) | |
| download | emacs-6514b30e6eb14e9d2364c08526dc8440a7412fef.tar.gz emacs-6514b30e6eb14e9d2364c08526dc8440a7412fef.zip | |
Fix vertical cursor motion across overlay strings with newlines
* src/indent.c (Fvertical_motion): Don't leave point in the middle
of an overlay string with newlines, as that will position the
cursor after the string at whatever column is there. (Bug#21468)
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/indent.c b/src/indent.c index 7e8f0a573a3..777cd36cc52 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -2195,7 +2195,30 @@ whether or not it is currently displayed in some window. */) | |||
| 2195 | was originally hscrolled, the goal column is interpreted as | 2195 | was originally hscrolled, the goal column is interpreted as |
| 2196 | an addition to the hscroll amount. */ | 2196 | an addition to the hscroll amount. */ |
| 2197 | if (lcols_given) | 2197 | if (lcols_given) |
| 2198 | move_it_in_display_line (&it, ZV, first_x + to_x, MOVE_TO_X); | 2198 | { |
| 2199 | move_it_in_display_line (&it, ZV, first_x + to_x, MOVE_TO_X); | ||
| 2200 | /* If we find ourselves in the middle of an overlay string | ||
| 2201 | which includes a newline after current string position, | ||
| 2202 | we need to move by lines until we get out of the string, | ||
| 2203 | and then reposition point at the requested X coordinate; | ||
| 2204 | if we don't, the cursor will be placed just after the | ||
| 2205 | string, which might not be the requested column. */ | ||
| 2206 | if (nlines > 0 | ||
| 2207 | && it.method == GET_FROM_STRING | ||
| 2208 | && !it.string_from_display_prop_p | ||
| 2209 | && it.area == TEXT_AREA) | ||
| 2210 | { | ||
| 2211 | while (it.method == GET_FROM_STRING | ||
| 2212 | && !it.string_from_display_prop_p | ||
| 2213 | && memchr (SSDATA (it.string) + IT_STRING_BYTEPOS (it), | ||
| 2214 | '\n', | ||
| 2215 | SBYTES (it.string) - IT_STRING_BYTEPOS (it))) | ||
| 2216 | { | ||
| 2217 | move_it_by_lines (&it, 1); | ||
| 2218 | move_it_in_display_line (&it, ZV, first_x + to_x, MOVE_TO_X); | ||
| 2219 | } | ||
| 2220 | } | ||
| 2221 | } | ||
| 2199 | 2222 | ||
| 2200 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 2223 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 2201 | bidi_unshelve_cache (itdata, 0); | 2224 | bidi_unshelve_cache (itdata, 0); |