aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/vi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 7ad8412a2..e59083ddb 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2422,9 +2422,10 @@ static int init_text_buffer(char *fn)
2422 2422
2423 update_filename(fn); 2423 update_filename(fn);
2424 rc = file_insert(fn, text, 1); 2424 rc = file_insert(fn, text, 1);
2425 if (rc < 0) { 2425 if (rc <= 0 || *(end - 1) != '\n') {
2426 // file doesnt exist. Start empty buf with dummy line 2426 // file doesn't exist or doesn't end in a newline.
2427 char_insert(text, '\n', NO_UNDO); 2427 // insert a newline to the end
2428 char_insert(end, '\n', NO_UNDO);
2428 } 2429 }
2429 2430
2430 flush_undo_data(); 2431 flush_undo_data();