[PATCH] Complete undo support for vi with intermediate queuing

jody at jodybruchon.com jody at jodybruchon.com
Sun Mar 23 20:30:19 UTC 2014


I have spent a lot of time working on it, and I finally have this patch for
complete undo support for BusyBox 'vi' with intermediate queuing capability.
This patch INCLUDES my previous "undo patch v3" and also fixes the following
issues with that patch:

* Cursor placement when undoing is now correct
* Undoing a 'dd' of the only line in the file no longer inserts a stray newline
* Undoing 'J' no longer randomly destroys the first char of the line

The biggest change is the "undo queuing" feature. When the undo queue feature is
compiled in, single-character operations such as typing and backspacing will be
grouped together. This greatly reduces malloc() calls while typing and makes
undo much more useful; instead of each 'u' keypress undoing one typed character,
all of the characters typed up to the queue size limit will be undone in one
shot.

The function undo_queue_commit() is called on certain keypresses to further
increase the usefulness of queuing. Changing between typing and backspacing or
moving the cursor during typing will "commit" the queue to an undo object,
thereby splitting them into logical groupings.

The queue size is configurable, the queue can be disabled, and undo support can
be disabled completely, which will compile BusyBox vi identically to how it is
built now. I have tested compilation AND as many of the possible text
manipulation functions as I could with all possible combinations of undo support
compiled in. I've tried to find bugs in the code in as many ways as possible,
and it seems to work correctly under everything I have thrown at it. I doubt
that this work on the undo feature can be improved any further.

Denys, would you mind trying this final patch out and applying it?

-Jody Bruchon


Signed-off-by: Jody Bruchon <jody at jodybruchon.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox_vi_undo_with_queuing_v1.patch
Type: text/x-diff
Size: 35300 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140323/a03439a0/attachment-0001.bin>


More information about the busybox mailing list