From 9856e2185f488477d974c4d373b0838bad2737fd Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Mon, 14 Apr 1997 08:50:23 +0000 Subject: [PATCH] (adjust_markers): Don't be confused by the gap when computing the arg to record_marker_adjustment. --- src/insdel.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/insdel.c b/src/insdel.c index aa431f58837..12b7eedb58b 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -274,8 +274,24 @@ adjust_markers (from, to, amount) but then this range contains no markers. */ if (mpos > from + amount && mpos <= from) { - record_marker_adjustment (marker, from + amount - mpos); - mpos = from + amount; + int before = mpos; + int after = from + amount; + + mpos = after; + + /* Compute the before and after positions + as buffer positions. */ + if (before > GPT + GAP_SIZE) + before -= GAP_SIZE; + else if (before > GPT) + before = GPT; + + if (after > GPT + GAP_SIZE) + after -= GAP_SIZE; + else if (after > GPT) + after = GPT; + + record_marker_adjustment (marker, after - before); } } if (mpos > from && mpos <= to) -- 2.39.5