summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-24 11:32:20 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-24 11:32:20 -0500
commit4aa02183b7f317ca1183b4d3e58ec9da166479d6 (patch)
tree6c03bb12002a4ca9c2f48620fa2a704c41e756de /menu.c
parentc101b231458da51767a79fb4b92304b1c76ef5e9 (diff)
big bugfixes
update active_tab properly when a tab is closed, fix Ctrl+O with no buffers open
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/menu.c b/menu.c
index c0ff5f4..89fafd0 100644
--- a/menu.c
+++ b/menu.c
@@ -2,7 +2,8 @@ static void menu_open(Ted *ted, Menu menu) {
if (ted->find) find_close(ted);
ted->menu = menu;
TextBuffer *prev_buf = ted->prev_active_buffer = ted->active_buffer;
- ted->prev_active_buffer_scroll = V2D(prev_buf->scroll_x, prev_buf->scroll_y);
+ if (prev_buf)
+ ted->prev_active_buffer_scroll = V2D(prev_buf->scroll_x, prev_buf->scroll_y);
ted->active_buffer = NULL;
*ted->warn_overwrite = 0; // clear warn_overwrite
@@ -35,8 +36,10 @@ static void menu_open(Ted *ted, Menu menu) {
static void menu_close(Ted *ted) {
TextBuffer *buffer = ted->active_buffer = ted->prev_active_buffer;
ted->prev_active_buffer = NULL;
- buffer->scroll_x = ted->prev_active_buffer_scroll.x;
- buffer->scroll_y = ted->prev_active_buffer_scroll.y;
+ if (buffer) {
+ buffer->scroll_x = ted->prev_active_buffer_scroll.x;
+ buffer->scroll_y = ted->prev_active_buffer_scroll.y;
+ }
switch (ted->menu) {
case MENU_NONE: assert(0); break;
case MENU_OPEN: