aboutsummaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/editor.c b/editor.c
index b3fd1de..bc3cbaa 100644
--- a/editor.c
+++ b/editor.c
@@ -1,6 +1,7 @@
#define _BSD_SOURCE
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "editor.h"
#include "util.h"
@@ -305,9 +306,11 @@ static EditorWin *editor_window_new_text(Editor *ed, Text *text) {
}
bool editor_window_new(Editor *ed, const char *filename) {
- Text *text = text_load(filename);
+ Text *text = text_load(filename && access(filename, R_OK) == 0 ? filename : NULL);
if (!text)
return false;
+ if (filename)
+ text_filename_set(text, filename);
EditorWin *win = editor_window_new_text(ed, text);
if (!win) {