diff options
| author | Eli Zaretskii | 2020-05-08 13:35:34 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-05-08 13:35:34 +0300 |
| commit | a76cafea0d55cc8df2a2c3556a628dac83762d9a (patch) | |
| tree | f0f88e5c2f6a4c9a2cec22d27ee959227a60ac65 /src | |
| parent | 76516465bff31d35ea93bcb2badb14c642bb5767 (diff) | |
| download | emacs-a76cafea0d55cc8df2a2c3556a628dac83762d9a.tar.gz emacs-a76cafea0d55cc8df2a2c3556a628dac83762d9a.zip | |
Fix handling of FROM = t and TO = t by 'window-text-pixel-size'
* src/xdisp.c (Fwindow_text_pixel_size): Use byte position for
accessing buffer text, not character positions. (Bug#41125)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 19f4f326186..c15dd4770ae 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -10442,7 +10442,7 @@ include the height of both, if present, in the return value. */) | |||
| 10442 | struct buffer *b; | 10442 | struct buffer *b; |
| 10443 | struct it it; | 10443 | struct it it; |
| 10444 | struct buffer *old_b = NULL; | 10444 | struct buffer *old_b = NULL; |
| 10445 | ptrdiff_t start, end, pos; | 10445 | ptrdiff_t start, end, bpos; |
| 10446 | struct text_pos startp; | 10446 | struct text_pos startp; |
| 10447 | void *itdata = NULL; | 10447 | void *itdata = NULL; |
| 10448 | int c, max_x = 0, max_y = 0, x = 0, y = 0; | 10448 | int c, max_x = 0, max_y = 0, x = 0, y = 0; |
| @@ -10457,32 +10457,56 @@ include the height of both, if present, in the return value. */) | |||
| 10457 | } | 10457 | } |
| 10458 | 10458 | ||
| 10459 | if (NILP (from)) | 10459 | if (NILP (from)) |
| 10460 | start = BEGV; | 10460 | { |
| 10461 | start = BEGV; | ||
| 10462 | bpos = BEGV_BYTE; | ||
| 10463 | } | ||
| 10461 | else if (EQ (from, Qt)) | 10464 | else if (EQ (from, Qt)) |
| 10462 | { | 10465 | { |
| 10463 | start = pos = BEGV; | 10466 | start = BEGV; |
| 10464 | while ((pos++ < ZV) && (c = FETCH_CHAR (pos)) | 10467 | bpos = BEGV_BYTE; |
| 10465 | && (c == ' ' || c == '\t' || c == '\n' || c == '\r')) | 10468 | while (bpos < ZV_BYTE) |
| 10466 | start = pos; | 10469 | { |
| 10467 | while ((pos-- > BEGV) && (c = FETCH_CHAR (pos)) && (c == ' ' || c == '\t')) | 10470 | FETCH_CHAR_ADVANCE (c, start, bpos); |
| 10468 | start = pos; | 10471 | if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) |
| 10472 | break; | ||
| 10473 | } | ||
| 10474 | while (bpos > BEGV_BYTE) | ||
| 10475 | { | ||
| 10476 | DEC_BOTH (start, bpos); | ||
| 10477 | c = FETCH_CHAR (bpos); | ||
| 10478 | if (!(c == ' ' || c == '\t')) | ||
| 10479 | break; | ||
| 10480 | } | ||
| 10469 | } | 10481 | } |
| 10470 | else | 10482 | else |
| 10471 | { | 10483 | { |
| 10472 | CHECK_FIXNUM_COERCE_MARKER (from); | 10484 | CHECK_FIXNUM_COERCE_MARKER (from); |
| 10473 | start = min (max (XFIXNUM (from), BEGV), ZV); | 10485 | start = min (max (XFIXNUM (from), BEGV), ZV); |
| 10486 | bpos = CHAR_TO_BYTE (start); | ||
| 10474 | } | 10487 | } |
| 10475 | 10488 | ||
| 10489 | SET_TEXT_POS (startp, start, bpos); | ||
| 10490 | |||
| 10476 | if (NILP (to)) | 10491 | if (NILP (to)) |
| 10477 | end = ZV; | 10492 | end = ZV; |
| 10478 | else if (EQ (to, Qt)) | 10493 | else if (EQ (to, Qt)) |
| 10479 | { | 10494 | { |
| 10480 | end = pos = ZV; | 10495 | end = ZV; |
| 10481 | while ((pos-- > BEGV) && (c = FETCH_CHAR (pos)) | 10496 | bpos = ZV_BYTE; |
| 10482 | && (c == ' ' || c == '\t' || c == '\n' || c == '\r')) | 10497 | while (bpos > BEGV_BYTE) |
| 10483 | end = pos; | 10498 | { |
| 10484 | while ((pos++ < ZV) && (c = FETCH_CHAR (pos)) && (c == ' ' || c == '\t')) | 10499 | DEC_BOTH (end, bpos); |
| 10485 | end = pos; | 10500 | c = FETCH_CHAR (bpos); |
| 10501 | if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) | ||
| 10502 | break; | ||
| 10503 | } | ||
| 10504 | while (bpos < ZV_BYTE) | ||
| 10505 | { | ||
| 10506 | FETCH_CHAR_ADVANCE (c, end, bpos); | ||
| 10507 | if (!(c == ' ' || c == '\t')) | ||
| 10508 | break; | ||
| 10509 | } | ||
| 10486 | } | 10510 | } |
| 10487 | else | 10511 | else |
| 10488 | { | 10512 | { |
| @@ -10499,7 +10523,6 @@ include the height of both, if present, in the return value. */) | |||
| 10499 | max_y = XFIXNUM (y_limit); | 10523 | max_y = XFIXNUM (y_limit); |
| 10500 | 10524 | ||
| 10501 | itdata = bidi_shelve_cache (); | 10525 | itdata = bidi_shelve_cache (); |
| 10502 | SET_TEXT_POS (startp, start, CHAR_TO_BYTE (start)); | ||
| 10503 | start_display (&it, w, startp); | 10526 | start_display (&it, w, startp); |
| 10504 | /* It makes no sense to measure dimensions of region of text that | 10527 | /* It makes no sense to measure dimensions of region of text that |
| 10505 | crosses the point where bidi reordering changes scan direction. | 10528 | crosses the point where bidi reordering changes scan direction. |