summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--node.c34
-rw-r--r--ted.c9
-rw-r--r--windows_installer/ted/ted.vdproj6
3 files changed, 24 insertions, 25 deletions
diff --git a/node.c b/node.c
index f224a7f..3d8d4b4 100644
--- a/node.c
+++ b/node.c
@@ -93,27 +93,12 @@ bool node_add_tab(Ted *ted, Node *node, TextBuffer *buffer) {
return true;
}
-static void node_switch_to_tab(Ted *ted, Node *node, u16 new_tab_index) {
- if (new_tab_index >= arr_len(node->tabs))
- return;
- if (new_tab_index == node->active_tab)
- return;
-
- node->active_tab = new_tab_index;
- if (node == ted->active_node) {
- // switch active buffer
- assert(node->tabs);
- TextBuffer *buffer = node->tabs[new_tab_index];
- ted_switch_to_buffer(ted, buffer);
- }
-}
-
// move n tabs to the right
void node_tab_next(Ted *ted, Node *node, i32 n) {
- u16 ntabs = (u16)arr_len(node->tabs);
+ u32 ntabs = arr_len(node->tabs);
if (!ntabs) return;
- u16 tab_idx = (u16)mod_i64((i64)node->active_tab + n, ntabs);
- node_switch_to_tab(ted, node, tab_idx);
+ u32 tab_idx = (u32)mod_i64((i64)node->active_tab + n, ntabs);
+ node_tab_switch(ted, node, tab_idx);
}
void node_tab_prev(Ted *ted, Node *node, i32 n) {
@@ -122,8 +107,15 @@ void node_tab_prev(Ted *ted, Node *node, i32 n) {
void node_tab_switch(Ted *ted, Node *node, u32 tab) {
assert(node->tabs);
- if (tab >= 0 && tab < node_tab_count(node)) {
- node_switch_to_tab(ted, node, (u16)tab);
+ if (tab >= arr_len(node->tabs))
+ return;
+
+ node->active_tab = (u16)tab;
+ if (node == ted->active_node) {
+ // switch active buffer
+ assert(node->tabs);
+ TextBuffer *buffer = node->tabs[tab];
+ ted_switch_to_buffer(ted, buffer);
}
}
@@ -311,7 +303,7 @@ void node_frame(Ted *ted, Node *node, Rect r) {
u16 tab_index = (u16)((click->pos.x - r.pos.x) / tab_width);
if (tab_index < arr_len(node->tabs)) {
ted->active_node = node;
- node_switch_to_tab(ted, node, tab_index);
+ node_tab_switch(ted, node, tab_index);
ted->dragging_tab_node = node;
ted->dragging_tab_idx = tab_index;
ted->dragging_tab_origin = click->pos;
diff --git a/ted.c b/ted.c
index 730280a..762b269 100644
--- a/ted.c
+++ b/ted.c
@@ -449,6 +449,9 @@ static Node *ted_buffer_location_in_node_tree(Ted *ted, TextBuffer *buffer, u16
}
void ted_switch_to_buffer(Ted *ted, TextBuffer *buffer) {
+ if (buffer == ted->active_buffer)
+ return;
+
TextBuffer *search_buffer = find_search_buffer(ted);
ted->active_buffer = buffer;
autocomplete_close(ted);
@@ -516,6 +519,7 @@ void ted_node_switch(Ted *ted, Node *node) {
while (node_child1(node)) {
node = node_child1(node);
}
+ ted->active_node = node;
ted_switch_to_buffer(ted, node_get_tab(node, node_active_tab(node)));
}
@@ -527,7 +531,7 @@ static TextBuffer *ted_open_buffer(Ted *ted, u16 *tab) {
if (!node) {
if (!arr_len(ted->nodes)) {
// no nodes open; create a root node
- node = ted->active_node = node_new(ted);
+ node = node_new(ted);
} else if (ted->prev_active_buffer) {
// opening a file while a menu is open
// it may happen.... (currently happens for rename symbol)
@@ -548,6 +552,9 @@ static TextBuffer *ted_open_buffer(Ted *ted, u16 *tab) {
u16 active_tab = (u16)(node_tab_count(node) - 1);
*tab = active_tab;
node_tab_switch(ted, node, active_tab);
+ ted->active_node = node;
+ ted->active_buffer = new_buffer;
+
return new_buffer;
}
diff --git a/windows_installer/ted/ted.vdproj b/windows_installer/ted/ted.vdproj
index ab166d3..a65a539 100644
--- a/windows_installer/ted/ted.vdproj
+++ b/windows_installer/ted/ted.vdproj
@@ -620,15 +620,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:ted"
- "ProductCode" = "8:{1065E316-820C-40EF-BE72-CCE18D421950}"
- "PackageCode" = "8:{14783293-5226-470A-A899-DEEC573CD8E6}"
+ "ProductCode" = "8:{51C543F8-F64F-4D57-ADAF-B7FF69EA8D1D}"
+ "PackageCode" = "8:{2553F30D-B299-4352-8C82-61883B4BE646}"
"UpgradeCode" = "8:{844F6C2B-DF3B-4A81-9BD5-603401BBA651}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:FALSE"
"InstallAllUsers" = "11:FALSE"
- "ProductVersion" = "8:23.08.0110"
+ "ProductVersion" = "8:23.08.1517"
"Manufacturer" = "8:ted"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"