diff options
author | Eli Zaretskii <eliz@gnu.org> | 2013-11-18 18:29:49 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2013-11-18 18:29:49 +0200 |
commit | 37c790b38599cc80a16c6a76152abbf8160fe2a1 (patch) | |
tree | a2f40d0acba8cdcf5c6502f4c07093f138772887 /src/insdel.c | |
parent | f2cbfd4442bf194bd277101357a86f96707ec36c (diff) | |
download | emacs-37c790b38599cc80a16c6a76152abbf8160fe2a1.tar.gz |
Fix bug #15841 with assertion violations due to newline cache.
src/insdel.c (invalidate_buffer_caches): New function, consolidated
from part of prepare_to_modify_buffer.
(insert_from_gap, prepare_to_modify_buffer):
src/coding.c (code_convert_region, code_convert_string): Call
invalidate_buffer_caches.
src/lisp.h (invalidate_buffer_caches): Add prototype.
Diffstat (limited to 'src/insdel.c')
-rw-r--r-- | src/insdel.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/insdel.c b/src/insdel.c index 5515b641d66..8de4f095396 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -993,6 +993,11 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail) if (NILP (BVAR (current_buffer, enable_multibyte_characters))) nchars = nbytes; + /* No need to call prepare_to_modify_buffer, since this is called + from places that replace some region with a different text, so + prepare_to_modify_buffer was already called by the deletion part + of this dance. */ + invalidate_buffer_caches (current_buffer, GPT, GPT); record_insert (GPT, nchars); MODIFF++; @@ -1869,19 +1874,26 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end, ptrdiff_t *preserve_ptr) { prepare_to_modify_buffer_1 (start, end, preserve_ptr); + invalidate_buffer_caches (current_buffer, start, end); +} - if (current_buffer->newline_cache) - invalidate_region_cache (current_buffer, - current_buffer->newline_cache, - start - BEG, Z - end); - if (current_buffer->width_run_cache) - invalidate_region_cache (current_buffer, - current_buffer->width_run_cache, - start - BEG, Z - end); - if (current_buffer->bidi_paragraph_cache) - invalidate_region_cache (current_buffer, - current_buffer->bidi_paragraph_cache, - start - BEG, Z - end); +/* Invalidate the caches maintained by the buffer BUF, if any, for the + region between buffer positions START and END. */ +void +invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) +{ + if (buf->newline_cache) + invalidate_region_cache (buf, + buf->newline_cache, + start - BUF_BEG (buf), BUF_Z (buf) - end); + if (buf->width_run_cache) + invalidate_region_cache (buf, + buf->width_run_cache, + start - BUF_BEG (buf), BUF_Z (buf) - end); + if (buf->bidi_paragraph_cache) + invalidate_region_cache (buf, + buf->bidi_paragraph_cache, + start - BUF_BEG (buf), BUF_Z (buf) - end); } /* These macros work with an argument named `preserve_ptr' |