vi: fix faulty undo after autoinsert
authorRon Yorston <rmy@pobox.com>
Sun, 3 Feb 2019 10:13:17 +0000 (10:13 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 8 Feb 2019 11:57:58 +0000 (12:57 +0100)
commitbb983f30e7ea69604212793f228270f21e8a5b06
tree6514127fdcfe5b03a33270320d6856267cc24029
parente6503f2f0982378cd753be152fa19f8336c357bc
vi: fix faulty undo after autoinsert

Enable autoinsert and enter the following with an indent of three
spaces:

   line 1
   line 2

Using 'u' to undo the last insert results in:

   line1e 2

The insertion of the indent hasn't been properly recorded.

Since recording insertions is a common operation add a convenience
function, undo_push_insert(), to handle this and use it to record
the autoindent correctly.

function                                             old     new   delta
undo_push_insert                                       -      36     +36
string_insert                                        133     129      -4
char_insert                                          518     473     -45
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 36/-49)            Total: -13 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/vi.c