vi Undo patch

Denys Vlasenko vda.linux at googlemail.com
Wed Apr 2 23:56:02 UTC 2014


On Wed, Apr 2, 2014 at 7:31 PM, Jody Bruchon <jody at jodybruchon.com> wrote:
> Denys, I've thrown this together which fixes the [Modified] not displaying.
> It looks like last_file_modified may be removable from the program entirely
> (it doesn't seem to actually be USED for anything) but I didn't want to do
> that just yet.

It seems to be used here:

        // reduce counting -- the total lines can't have
        // changed if we haven't done any edits.
        if (file_modified != last_file_modified) {
                tot = cur + count_lines(dot, end - 1) - 1;
                last_file_modified = file_modified;
        }


> I confirmed that this shows [Modified] the instant one makes a change, and
> when the undo stack is emptied out (and thus all modifications removed) it
> stops showing [Modified].

I thought about it a bit more and I think it's ok as-is:
[Modified] will appear anyway when user goes to command mode.
Thus, for example, accidental quitting without saving is not possible.


Next issue:
Looks like undo depth is not bounded?
What if user repeatedly inserts and deletes text ad infinitum -
will we eventually oom?
Do we even *want* to fix it?
"Undo as long as you have RAM" has its appeal too ;)


More information about the busybox mailing list