commit cb029377146f9cce87f0532ab55b4855c2f10738
parent 1327e296c2bfb947778c882e6132d0b572eb921e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 25 Apr 2024 10:44:48 +0200
wrapping: delete only single characters, not a possibly marked region
These calls of do_delete() were meant to delete just one character,
but over time do_delete() morphed into doing also other things...
Change the calls to invoke the correct function instead.
(This also avoids snipping any zero-width characters that come after
a snipped space, as that is probably not what the user wants.)
This fixes https://savannah.gnu.org/bugs/?65636.
The issue was reported by `correctmost`.
Bug existed since version 3.2, commit ae3ec178,
when --zap was introduced.
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -253,6 +253,7 @@ void precalc_multicolorinfo(void);
#endif
/* Most functions in cut.c. */
+void expunge(undo_type action);
void do_delete(void);
void do_backspace(void);
#ifndef NANO_TINY
diff --git a/src/text.c b/src/text.c
@@ -1307,18 +1307,18 @@ void do_wrap(void)
}
/* Join the next line to this one. */
- do_delete();
+ expunge(DEL);
#ifdef ENABLE_JUSTIFY
/* If the leading part of the current line equals the leading part of
* what was the next line, then strip this second leading part. */
if (strncmp(line->data, line->data + openfile->current_x, lead_len) == 0)
for (size_t i = lead_len; i > 0; i--)
- do_delete();
+ expunge(DEL);
#endif
/* Remove any extra blanks. */
while (is_blank_char(&line->data[openfile->current_x]))
- do_delete();
+ expunge(DEL);
}
/* Go to the wrap location. */
@@ -1332,7 +1332,7 @@ void do_wrap(void)
while ((rear_x != typed_x || cursor_x >= wrap_loc) &&
is_blank_char(line->data + rear_x)) {
openfile->current_x = rear_x;
- do_delete();
+ expunge(DEL);
rear_x = step_left(line->data, rear_x);
}
}