[Toybox] [PATCH] vi: add "w <filename>".
enh
enh at google.com
Sun Jan 29 11:03:45 PST 2023
(Issues reported by an Android partner; basically "vi" with no arguments
is broken, and "vi foo" where foo doesn't yet exist is broken, and even
if they weren't, ":w filename" isn't implemented. This patch fixes the
last of those more convincingly than the other two.)
Don't crash (or write '(null).swp') when started with no filename;
refuse to write without a filename (with ":w filename" being the
workaround).
Also fix insert to work when started with a filename where no such file
yet exists. (This appears to still be buggy in some cases, depending
on the exact sequence of editing operations performed. An 'i' followed
by an 'A' for example suggests that there's an off-by-one in the whole
block_list/slice_list thing. I still think we should just replace that
with an easy to get right https://en.wikipedia.org/wiki/Gap_buffer
instead, or even just the trivial case where the gap is always at the
end! Especially when we come to dealing with stuff like undo/redo...)
Also add basic error reporting similar to hexedit. This (and the notion
of a status line that would help make both even better, in particular
removing the bogus "should be long enough" sleeps, should probably end
up in tty.c, but this is better than nothing.)
Also simplify the three (0/1/-1) return values from run_ex_cmd(),
which appears to have been a bug anyway.
Also document that TT.modified isn't actually updated (a bug that would
be a lot easier to fix with a simpler text representation). This means
that although I've added the missing ":q" warning for modified files, it
doesn't actually ever fire yet.
Bug: https://issuetracker.google.com/242636400
---
toys/pending/vi.c | 114 +++++++++++++++++++++++++++++-----------------
1 file changed, 71 insertions(+), 43 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20230129/fad9c4c5/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vi-add-w-filename.patch
Type: text/x-patch
Size: 7272 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20230129/fad9c4c5/attachment.bin>
More information about the Toybox
mailing list