From d1eb042871f2da438286f15c65b0020bdac10f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 10 Sep 2014 14:12:53 +0200 Subject: If text has been created from an empty file, store filename upon first save --- text.c | 2 ++ text.h | 1 + 2 files changed, 3 insertions(+) diff --git a/text.c b/text.c index 9879f98..39d47cc 100644 --- a/text.c +++ b/text.c @@ -610,6 +610,8 @@ int text_save(Text *txt, const char *filename) { return -1; txt->saved_action = txt->undo; text_snapshot(txt); + if (!txt->filename) + txt->filename = strdup(filename); return 0; err: close(fd); diff --git a/text.h b/text.h index e133af0..bedd16b 100644 --- a/text.h +++ b/text.h @@ -27,6 +27,7 @@ typedef struct { text_iterator_next(&it)) Text *text_load(const char *file); +/* the filename from which this text was loaded or first saved to */ const char *text_filename(Text*); bool text_insert(Text*, size_t pos, const char *data); bool text_insert_raw(Text*, size_t pos, const char *data, size_t len); -- cgit v1.2.3