The problem can be reproduced by creating a file with some text that
does not end in a newline:
$ printf test > test
$ vi test
<press 'o'>
The last character will be placed on the next line as well. Problems can
be seen with the 'A' command too.
This patch should fix the problems.
---
editors/vi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/editors/vi.c b/editors/vi.c
index 2645afe87..ca8130722 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -556,6 +556,7 @@ static int crashme = 0;
static void show_status_line(void); // put a message on the bottom line
static void status_line_bold(const char *, ...);
+static char *char_insert(char *p, char c, int undo);
static void show_help(void)
{
@@ -1830,6 +1831,10 @@ static void dot_end(void)
{
undo_queue_commit();
dot = end_line(dot); // return pointer to last char cur line
+ if (*dot != '\n') {
+ /* There was no EOL, so create one. */
+ dot = char_insert(dot + 1, '\n', NO_UNDO) - 1;
+ }
}
static char *move_to_col(char *p, int l)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox