aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c
index a26e8010f7f..0e6f8b3aff0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2607,6 +2607,8 @@ and (2) it puts less data in the undo list.")
2607 char buffer[1 << 14]; 2607 char buffer[1 << 14];
2608 int same_at_start = BEGV; 2608 int same_at_start = BEGV;
2609 int same_at_end = ZV; 2609 int same_at_end = ZV;
2610 int overlap;
2611
2610 immediate_quit = 1; 2612 immediate_quit = 1;
2611 QUIT; 2613 QUIT;
2612 /* Count how many chars at the start of the file 2614 /* Count how many chars at the start of the file
@@ -2678,9 +2680,16 @@ and (2) it puts less data in the undo list.")
2678 break; 2680 break;
2679 } 2681 }
2680 immediate_quit = 0; 2682 immediate_quit = 0;
2683
2684 /* Don't try to reuse the same piece of text twice. */
2685 overlap = same_at_start - BEGV - (same_at_end + st.st_size - ZV);
2686 if (overlap > 0)
2687 same_at_end += overlap;
2688
2681 /* Arrange to read only the nonmatching middle part of the file. */ 2689 /* Arrange to read only the nonmatching middle part of the file. */
2682 XFASTINT (beg) = same_at_start - BEGV; 2690 XFASTINT (beg) = same_at_start - BEGV;
2683 XFASTINT (end) = st.st_size - (ZV - same_at_end); 2691 XFASTINT (end) = st.st_size - (ZV - same_at_end);
2692
2684 del_range_1 (same_at_start, same_at_end, 0); 2693 del_range_1 (same_at_start, same_at_end, 0);
2685 /* Insert from the file at the proper position. */ 2694 /* Insert from the file at the proper position. */
2686 SET_PT (same_at_start); 2695 SET_PT (same_at_start);