This fixes the use of `:r` with empty files. function old new delta undo_pop 238 242 +4
Signed-off-by: Petja Patjas <[email protected]> --- editors/vi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/editors/vi.c b/editors/vi.c index 06d446970..9575a1246 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -1766,9 +1766,11 @@ static void undo_pop(void) case UNDO_INS: case UNDO_INS_CHAIN: // delete what was inserted - u_start = undo_entry->start + text; - u_end = u_start - 1 + undo_entry->length; - text_hole_delete(u_start, u_end, NO_UNDO); + if (undo_entry->length != 0) { + u_start = undo_entry->start + text; + u_end = u_start - 1 + undo_entry->length; + text_hole_delete(u_start, u_end, NO_UNDO); + } # if ENABLE_FEATURE_VI_VERBOSE_STATUS status_line("Undo [%d] %s %d chars at position %d", modified_count, "deleted", -- 2.51.0 _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
