diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 4031571dd99..dc5101d5aca 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3632,7 +3632,45 @@ compute_stop_pos (struct it *it) | |||
| 3632 | /* Set up variables for computing the stop position from text | 3632 | /* Set up variables for computing the stop position from text |
| 3633 | property changes. */ | 3633 | property changes. */ |
| 3634 | XSETBUFFER (object, current_buffer); | 3634 | XSETBUFFER (object, current_buffer); |
| 3635 | limit = make_fixnum (IT_CHARPOS (*it) + TEXT_PROP_DISTANCE_LIMIT); | 3635 | pos = charpos + TEXT_PROP_DISTANCE_LIMIT; |
| 3636 | /* Make sure the above arbitrary limit position is not in the | ||
| 3637 | middle of composable text, so we don't break compositions by | ||
| 3638 | submitting the composable text to the shaper in separate | ||
| 3639 | chunks. We play safe here by assuming that only SPC, TAB, | ||
| 3640 | FF, and NL cannot be in some composition; in particular, most | ||
| 3641 | ASCII punctuation characters could be composed into ligatures. */ | ||
| 3642 | if (!NILP (BVAR (current_buffer, enable_multibyte_characters)) | ||
| 3643 | && !NILP (Vauto_composition_mode)) | ||
| 3644 | { | ||
| 3645 | ptrdiff_t endpos = charpos + 10 * TEXT_PROP_DISTANCE_LIMIT; | ||
| 3646 | bool found = false; | ||
| 3647 | |||
| 3648 | if (pos > ZV) | ||
| 3649 | pos = ZV; | ||
| 3650 | if (endpos > ZV) | ||
| 3651 | endpos = ZV; | ||
| 3652 | ptrdiff_t bpos = CHAR_TO_BYTE (pos); | ||
| 3653 | while (pos < endpos) | ||
| 3654 | { | ||
| 3655 | int ch; | ||
| 3656 | FETCH_CHAR_ADVANCE_NO_CHECK (ch, pos, bpos); | ||
| 3657 | if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\f') | ||
| 3658 | { | ||
| 3659 | found = true; | ||
| 3660 | break; | ||
| 3661 | } | ||
| 3662 | } | ||
| 3663 | if (found) | ||
| 3664 | pos--; | ||
| 3665 | else if (it->stop_charpos < endpos) | ||
| 3666 | pos = it->stop_charpos; | ||
| 3667 | else | ||
| 3668 | { | ||
| 3669 | /* Give up and use the original arbitrary limit. */ | ||
| 3670 | pos = charpos + TEXT_PROP_DISTANCE_LIMIT; | ||
| 3671 | } | ||
| 3672 | } | ||
| 3673 | limit = make_fixnum (pos); | ||
| 3636 | } | 3674 | } |
| 3637 | 3675 | ||
| 3638 | /* Get the interval containing IT's position. Value is a null | 3676 | /* Get the interval containing IT's position. Value is a null |