aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2013-11-27 18:08:53 +0200
committerEli Zaretskii <[email protected]>2013-11-27 18:08:53 +0200
commitde1e0d91fe4f58aa35d8071966d978a70c349a08 (patch)
treea37e0000ce66cdfdc5dd2959b58c9397f9f47dfb
parentfb6a5d68e3cbb993a9c72f0bf20e74951e873e72 (diff)
Fix bug #15973 with erratic cursor motion after reverting a buffer.
src/fileio.c (Finsert_file_contents): Invalidate buffer caches when deleting portions of the buffer under non-nil REPLACE argument.
-rw-r--r--src/ChangeLog4
-rw-r--r--src/fileio.c13
2 files changed, 16 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b43f758cec..89d1fb3077 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2013-11-27 Eli Zaretskii <[email protected]>
+ * fileio.c (Finsert_file_contents): Invalidate buffer caches when
+ deleting portions of the buffer under non-nil REPLACE argument.
+ (Bug#15973)
+
* w32notify.c (Fw32notify_add_watch): If the argument FILE is a
directory, watch it and not its parent.
(add_watch): Allow empty string in FILE.
diff --git a/src/fileio.c b/src/fileio.c
index 07d3601618..a0603b490d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3858,6 +3858,9 @@ by calling `format-decode', which see. */)
beg_offset += same_at_start - BEGV_BYTE;
end_offset -= ZV_BYTE - same_at_end;
+ invalidate_buffer_caches (current_buffer,
+ BYTE_TO_CHAR (same_at_start),
+ BYTE_TO_CHAR (same_at_end));
del_range_byte (same_at_start, same_at_end, 0);
/* Insert from the file at the proper position. */
temp = BYTE_TO_CHAR (same_at_start);
@@ -3968,7 +3971,12 @@ by calling `format-decode', which see. */)
{
/* Truncate the buffer to the size of the file. */
if (same_at_start != same_at_end)
- del_range_byte (same_at_start, same_at_end, 0);
+ {
+ invalidate_buffer_caches (current_buffer,
+ BYTE_TO_CHAR (same_at_start),
+ BYTE_TO_CHAR (same_at_end));
+ del_range_byte (same_at_start, same_at_end, 0);
+ }
inserted = 0;
unbind_to (this_count, Qnil);
@@ -4016,6 +4024,9 @@ by calling `format-decode', which see. */)
if (same_at_end != same_at_start)
{
+ invalidate_buffer_caches (current_buffer,
+ BYTE_TO_CHAR (same_at_start),
+ BYTE_TO_CHAR (same_at_end));
del_range_byte (same_at_start, same_at_end, 0);
temp = GPT;
eassert (same_at_start == GPT_BYTE);