summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/menu.c b/menu.c
index ae69eac..5a0e964 100644
--- a/menu.c
+++ b/menu.c
@@ -1,4 +1,4 @@
-static void menu_close(Ted *ted) {
+static void menu_close_with_next(Ted *ted, Menu next) {
ted_switch_to_buffer(ted, ted->prev_active_buffer);
TextBuffer *buffer = ted->active_buffer;
ted->prev_active_buffer = NULL;
@@ -14,8 +14,10 @@ static void menu_close(Ted *ted) {
buffer_clear(&ted->line_buffer);
break;
case MENU_WARN_UNSAVED:
- ted->warn_unsaved = 0;
- *ted->warn_unsaved_names = 0;
+ if (next != MENU_WARN_UNSAVED) {
+ ted->warn_unsaved = 0;
+ *ted->warn_unsaved_names = 0;
+ }
break;
case MENU_ASK_RELOAD:
*ted->ask_reload = 0;
@@ -40,9 +42,13 @@ static void menu_close(Ted *ted) {
ted->selector_open = NULL;
}
-static void menu_open(Ted *ted, Menu menu) {
+void menu_close(Ted *ted) {
+ menu_close_with_next(ted, 0);
+}
+
+void menu_open(Ted *ted, Menu menu) {
if (ted->menu)
- menu_close(ted);
+ menu_close_with_next(ted, menu);
if (ted->find) find_close(ted);
ted->autocomplete = false;
ted->menu = menu;