summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-05 16:49:17 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-05 16:49:17 -0500
commitedbad154a65f47dc77dbb901801651e28c4f5e55 (patch)
tree544d1e29f7507622a0a58c906fea0ddf500393af /session.c
parente37ef801a6304f602fdff195b2c46098cf7f5994 (diff)
fix :shell with no files open, write cwd to session
Diffstat (limited to 'session.c')
-rw-r--r--session.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/session.c b/session.c
index 5a07afb..8e2061d 100644
--- a/session.c
+++ b/session.c
@@ -1,5 +1,5 @@
#define SESSION_FILENAME "session.txt"
-#define SESSION_VERSION "\x7fTED0001"
+#define SESSION_VERSION "\x7fTED0002"
static void session_write_node(Ted *ted, FILE *fp, u16 node_idx) {
Node *node = &ted->nodes[node_idx];
@@ -95,6 +95,8 @@ static void session_read_buffer(Ted *ted, FILE *fp) {
static void session_write_file(Ted *ted, FILE *fp) {
fwrite(SESSION_VERSION, 1, sizeof SESSION_VERSION, fp);
+ write_cstr(fp, ted->cwd);
+
write_u16(fp, ted->active_node ? (u16)(ted->active_node - ted->nodes) : U16_MAX); // active node idx
write_u16(fp, ted->active_buffer ? (u16)(ted->active_buffer - ted->buffers) : U16_MAX); // active buffer idx
@@ -123,6 +125,8 @@ static void session_read_file(Ted *ted, FILE *fp) {
return; // wrong version
}
+ read_cstr(fp, ted->cwd, sizeof ted->cwd);
+
u16 active_node_idx = read_u16(fp);
u16 active_buffer_idx = read_u16(fp);