diff options
| author | Eli Zaretskii | 2020-04-15 14:28:21 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-15 14:28:21 +0300 |
| commit | bedb3cb66541fd4dd35cf15261c6d99f132e7d2c (patch) | |
| tree | 59e9609812951c8c7606c0b15481366a245a2e3e /src | |
| parent | 72fc8ec6dd013e6964d58bf624e2b5ebf4177a64 (diff) | |
| download | emacs-bedb3cb66541fd4dd35cf15261c6d99f132e7d2c.tar.gz emacs-bedb3cb66541fd4dd35cf15261c6d99f132e7d2c.zip | |
Avoid infloop in redisplay when wrap-prefix is too wide
* src/xdisp.c (move_it_to): Avoid infloop due to wrap-prefix that
is wide enough to leave no space to display even the first
character of the continuation line. (Bug#40632)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 193cc372b0e..cce434e6665 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -9662,9 +9662,13 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos | |||
| 9662 | int line_height, line_start_x = 0, reached = 0; | 9662 | int line_height, line_start_x = 0, reached = 0; |
| 9663 | int max_current_x = 0; | 9663 | int max_current_x = 0; |
| 9664 | void *backup_data = NULL; | 9664 | void *backup_data = NULL; |
| 9665 | ptrdiff_t orig_charpos = -1; | ||
| 9666 | enum it_method orig_method = NUM_IT_METHODS; | ||
| 9665 | 9667 | ||
| 9666 | for (;;) | 9668 | for (;;) |
| 9667 | { | 9669 | { |
| 9670 | orig_charpos = IT_CHARPOS (*it); | ||
| 9671 | orig_method = it->method; | ||
| 9668 | if (op & MOVE_TO_VPOS) | 9672 | if (op & MOVE_TO_VPOS) |
| 9669 | { | 9673 | { |
| 9670 | /* If no TO_CHARPOS and no TO_X specified, stop at the | 9674 | /* If no TO_CHARPOS and no TO_X specified, stop at the |
| @@ -9898,7 +9902,17 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos | |||
| 9898 | } | 9902 | } |
| 9899 | } | 9903 | } |
| 9900 | else | 9904 | else |
| 9901 | it->continuation_lines_width += it->current_x; | 9905 | { |
| 9906 | /* Make sure we do advance, otherwise we might infloop. | ||
| 9907 | This could happen when the first display element is | ||
| 9908 | wider than the window, or if we have a wrap-prefix | ||
| 9909 | that doesn't leave enough space after it to display | ||
| 9910 | even a single character. */ | ||
| 9911 | if (IT_CHARPOS (*it) == orig_charpos | ||
| 9912 | && it->method == orig_method) | ||
| 9913 | set_iterator_to_next (it, false); | ||
| 9914 | it->continuation_lines_width += it->current_x; | ||
| 9915 | } | ||
| 9902 | break; | 9916 | break; |
| 9903 | 9917 | ||
| 9904 | default: | 9918 | default: |