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.
This commit is contained in:
Benno Schulenberg 2024-04-25 10:44:48 +02:00
parent 1327e296c2
commit cb02937714
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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);
}
}