diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-24 11:32:20 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-24 11:32:20 -0500 |
commit | 4aa02183b7f317ca1183b4d3e58ec9da166479d6 (patch) | |
tree | 6c03bb12002a4ca9c2f48620fa2a704c41e756de /node.c | |
parent | c101b231458da51767a79fb4b92304b1c76ef5e9 (diff) |
big bugfixes
update active_tab properly when a tab is closed, fix Ctrl+O with no buffers open
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -69,7 +69,9 @@ static bool node_tab_close(Ted *ted, Node *node, u16 index) { ntabs = (u16)arr_len(node->tabs); // update ntabs assert(ntabs); - // make sure active tab is valid + // fix active_tab + if (index < node->active_tab) + --node->active_tab; node->active_tab = clamp_u16(node->active_tab, 0, ntabs - 1); if (ted->active_node == node) { // fix active buffer if necessary @@ -104,6 +106,7 @@ static void node_frame(Ted *ted, Node *node, Rect r) { } } for (u16 c = 0; c < ted->nmouse_clicks[SDL_BUTTON_MIDDLE]; ++c) { + // middle-click to close tab v2 click = ted->mouse_clicks[SDL_BUTTON_MIDDLE][c]; if (rect_contains_point(tab_bar_rect, click)) { u16 tab_index = (u16)((click.x - r.pos.x) / tab_width); |