From 0a41199524577dadaf29652a6edb5bcd07b3560c Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Tue, 13 Feb 2001 16:29:20 +0000 Subject: [PATCH] (del_range_1, del_range_byte, del_range_both): Handle case that TO ends up beyond ZV after running before-change-functions. --- src/ChangeLog | 3 +++ src/insdel.c | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 670e999a9ea..3d7451da8ad 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2001-02-13 Gerd Moellmann + * insdel.c (del_range_1, del_range_byte, del_range_both): Handle + case that TO ends up beyond ZV after running before-change-functions. + * window.c (window_loop) : Prefer to return the selected window if it is showing the buffer in question. diff --git a/src/insdel.c b/src/insdel.c index 5574f850e83..7ea1181703b 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -1552,7 +1552,7 @@ del_range_1 (from, to, prepare, ret_string) { int range_length = to - from; prepare_to_modify_buffer (from, to, &from); - to = from + range_length; + to = min (ZV, from + range_length); } from_byte = CHAR_TO_BYTE (from); @@ -1595,7 +1595,12 @@ del_range_byte (from_byte, to_byte, prepare) if (old_from != from) from_byte = CHAR_TO_BYTE (from); - if (old_to == Z - to) + if (to > ZV) + { + to = ZV; + to_byte = ZV_BYTE; + } + else if (old_to == Z - to) to_byte = CHAR_TO_BYTE (to); } @@ -1634,7 +1639,12 @@ del_range_both (from, from_byte, to, to_byte, prepare) if (old_from != from) from_byte = CHAR_TO_BYTE (from); - if (old_to == Z - to) + if (to > ZV) + { + to = ZV; + to_byte = ZV_BYTE; + } + else if (old_to == Z - to) to_byte = CHAR_TO_BYTE (to); } -- 2.39.5