diff options
| author | Eli Zaretskii | 2018-03-08 15:32:23 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-06-02 12:17:16 +0300 |
| commit | f1f12d8be3ddc5aa0a79658f5b339c78742321fa (patch) | |
| tree | 4271535474d67dea7619e343426e4fbe090071d6 /src | |
| parent | 8b2b4b580c38d7f1d95f8b2bf1f7c6ad8b9207b9 (diff) | |
| download | emacs-f1f12d8be3ddc5aa0a79658f5b339c78742321fa.tar.gz emacs-f1f12d8be3ddc5aa0a79658f5b339c78742321fa.zip | |
Fix 'window-text-pixel-size' when display properties are around
* src/xdisp.c (Fwindow_text_pixel_size): Correct the result when
there's a display property at the TO position, and the call to
move_it_to overshoots. (Bug#30746)
(cherry picked from commit 50e2c0fb5180a757d8d533518f68837ffe5909be)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 5a301e4090f..419187376f5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -10138,17 +10138,46 @@ include the height of both, if present, in the return value. */) | |||
| 10138 | itdata = bidi_shelve_cache (); | 10138 | itdata = bidi_shelve_cache (); |
| 10139 | SET_TEXT_POS (startp, start, CHAR_TO_BYTE (start)); | 10139 | SET_TEXT_POS (startp, start, CHAR_TO_BYTE (start)); |
| 10140 | start_display (&it, w, startp); | 10140 | start_display (&it, w, startp); |
| 10141 | 10141 | /* It makes no sense to measure dimensions of region of text that | |
| 10142 | if (NILP (x_limit)) | 10142 | crosses the point where bidi reordering changes scan direction. |
| 10143 | x = move_it_to (&it, end, -1, max_y, -1, MOVE_TO_POS | MOVE_TO_Y); | 10143 | By using unidirectional movement here we at least support the use |
| 10144 | else | 10144 | case of measuring regions of text that have a uniformly R2L |
| 10145 | directionality, and regions that begin and end in text of the | ||
| 10146 | same directionality. */ | ||
| 10147 | it.bidi_p = false; | ||
| 10148 | void *it2data = NULL; | ||
| 10149 | struct it it2; | ||
| 10150 | SAVE_IT (it2, it, it2data); | ||
| 10151 | |||
| 10152 | int move_op = MOVE_TO_POS | MOVE_TO_Y; | ||
| 10153 | int to_x = -1; | ||
| 10154 | if (!NILP (x_limit)) | ||
| 10145 | { | 10155 | { |
| 10146 | it.last_visible_x = max_x; | ||
| 10147 | /* Actually, we never want move_it_to stop at to_x. But to make | 10156 | /* Actually, we never want move_it_to stop at to_x. But to make |
| 10148 | sure that move_it_in_display_line_to always moves far enough, | 10157 | sure that move_it_in_display_line_to always moves far enough, |
| 10149 | we set it to INT_MAX and specify MOVE_TO_X. */ | 10158 | we set to_x to INT_MAX and specify MOVE_TO_X. */ |
| 10150 | x = move_it_to (&it, end, INT_MAX, max_y, -1, | 10159 | move_op |= MOVE_TO_X; |
| 10151 | MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); | 10160 | to_x = INT_MAX; |
| 10161 | } | ||
| 10162 | |||
| 10163 | x = move_it_to (&it, end, to_x, max_y, -1, move_op); | ||
| 10164 | |||
| 10165 | /* We could have a display property at END, in which case asking | ||
| 10166 | move_it_to to stop at END will overshoot and stop at position | ||
| 10167 | after END. So we try again, stopping before END, and account for | ||
| 10168 | the width of the last buffer position manually. */ | ||
| 10169 | if (IT_CHARPOS (it) > end) | ||
| 10170 | { | ||
| 10171 | end--; | ||
| 10172 | RESTORE_IT (&it, &it2, it2data); | ||
| 10173 | x = move_it_to (&it, end, to_x, max_y, -1, move_op); | ||
| 10174 | /* Add the width of the thing at TO, but only if we didn't | ||
| 10175 | overshoot it; if we did, it is already accounted for. */ | ||
| 10176 | if (IT_CHARPOS (it) == end) | ||
| 10177 | x += it.pixel_width; | ||
| 10178 | } | ||
| 10179 | if (!NILP (x_limit)) | ||
| 10180 | { | ||
| 10152 | /* Don't return more than X-LIMIT. */ | 10181 | /* Don't return more than X-LIMIT. */ |
| 10153 | if (x > max_x) | 10182 | if (x > max_x) |
| 10154 | x = max_x; | 10183 | x = max_x; |