aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/vi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 3cc3d2a0b..34932f60c 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2315,9 +2315,10 @@ static int init_text_buffer(char *fn)
2315 2315
2316 update_filename(fn); 2316 update_filename(fn);
2317 rc = file_insert(fn, text, 1); 2317 rc = file_insert(fn, text, 1);
2318 if (rc < 0) { 2318 if (rc <= 0 || *(end - 1) != '\n') {
2319 // file doesnt exist. Start empty buf with dummy line 2319 // file doesn't exist or doesn't end in a newline.
2320 char_insert(text, '\n', NO_UNDO); 2320 // insert a newline to the end
2321 char_insert(end, '\n', NO_UNDO);
2321 } 2322 }
2322 2323
2323 flush_undo_data(); 2324 flush_undo_data();