From 5cf3d9bc2c9828baddbbe813b579429ccfc090f4 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 22 Jun 2023 18:23:04 -0700 Subject: [PATCH] save to disk when leaving thread view --- 0023-on.keychord_press | 1 + 0137-quit_all_editors | 9 +++++++++ 0138-on.quit | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 0137-quit_all_editors create mode 100644 0138-on.quit diff --git a/0023-on.keychord_press b/0023-on.keychord_press index cdca4e1..2afb043 100644 --- a/0023-on.keychord_press +++ b/0023-on.keychord_press @@ -1,6 +1,7 @@ on.keychord_press = function(chord, key) print('key', chord) if Global_state.thread and chord == 'C-o' then + quit_all_editors(Global_state.thread) Global_state.thread = nil reset_viewport() A() diff --git a/0137-quit_all_editors b/0137-quit_all_editors new file mode 100644 index 0000000..68f3ab5 --- /dev/null +++ b/0137-quit_all_editors @@ -0,0 +1,9 @@ +quit_all_editors = function(node) + if node.type == 'text' and not node.button then + edit.quit(node.editor) + elseif node.type == 'rows' or node.type == 'cols' then + for _,child in ipairs(node.data) do + quit_all_editors(child, dt) + end + end +end \ No newline at end of file diff --git a/0138-on.quit b/0138-on.quit new file mode 100644 index 0000000..ebe45b0 --- /dev/null +++ b/0138-on.quit @@ -0,0 +1,5 @@ +on.quit = function() + if Global_state.thread then + quit_all_editors(Global_state.thread) + end +end \ No newline at end of file