Skip to content

Commit 58e051d

Browse files
committed
fix: tab click gives focus to active tab
1 parent 9c4d2ed commit 58e051d

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/editor_app.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ void EditorApp::load_fonts() {
776776
// Try to load user-selected font
777777
if (!settings_.font_name.empty()) {
778778
#ifdef _WIN32
779-
std::vector<std::string> exts = {".ttc", ".ttf", ".otf"}; // Try .ttc first
779+
std::vector<std::string> exts = {".ttc", ".ttf", ".otf"};
780780
for (const auto& ext : exts) {
781781
std::string path = "C:/Windows/Fonts/" + settings_.font_name + ext;
782782
font = io.Fonts->AddFontFromFileTTF(path.c_str(), (float)settings_.font_size);
@@ -793,8 +793,6 @@ void EditorApp::load_fonts() {
793793
font_size_temp_ = settings_.font_size;
794794
font_name_temp_ = settings_.font_name;
795795

796-
// Don't call Build() - the backend handles it automatically on first render
797-
// Just set the global scale
798796
float scale = (float)settings_.font_size / 16.0f;
799797
io.FontGlobalScale = scale;
800798
}
@@ -814,7 +812,7 @@ void EditorApp::rebuild_fonts() {
814812
// Try to load user-selected font
815813
if (!settings_.font_name.empty()) {
816814
#ifdef _WIN32
817-
std::vector<std::string> exts = {".ttc", ".ttf", ".otf"}; // Try .ttc first
815+
std::vector<std::string> exts = {".ttc", ".ttf", ".otf"};
818816
for (const auto& ext : exts) {
819817
std::string path = "C:/Windows/Fonts/" + settings_.font_name + ext;
820818
font = io.Fonts->AddFontFromFileTTF(path.c_str(), (float)settings_.font_size);
@@ -828,8 +826,6 @@ void EditorApp::rebuild_fonts() {
828826
font = io.Fonts->AddFontDefault();
829827
}
830828

831-
// Don't call Build() - the backend handles it automatically
832-
// Just apply scale
833829
float scale = (float)settings_.font_size / 16.0f;
834830
io.FontGlobalScale = scale;
835831
}
@@ -1122,7 +1118,11 @@ void EditorApp::render_editor_area() {
11221118

11231119
bool open = true;
11241120
if (ImGui::BeginTabItem(label.c_str(), &open, tab_item_flags)) {
1125-
active_tab_ = i;
1121+
if (active_tab_ != i) {
1122+
active_tab_ = i;
1123+
// Focus on the new tab's editor
1124+
ImGui::SetWindowFocus("Editor");
1125+
}
11261126

11271127
// Render gutter with bookmarks and change history
11281128
render_editor_with_margins();
@@ -1222,8 +1222,6 @@ void EditorApp::render_status_bar() {
12221222
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 2));
12231223

12241224
if (ImGui::Begin("StatusBar", nullptr, flags)) {
1225-
ImGui::PopStyleVar(2);
1226-
12271225
if (active_tab_ >= 0 && active_tab_ < (int)tabs_.size()) {
12281226
auto& tab = tabs_[active_tab_];
12291227
auto pos = tab.editor->GetCursorPosition();
@@ -1273,9 +1271,8 @@ void EditorApp::render_status_bar() {
12731271
}
12741272

12751273
ImGui::End();
1276-
} else {
1277-
ImGui::PopStyleVar(2);
12781274
}
1275+
ImGui::PopStyleVar(2);
12791276
}
12801277

12811278
// ============================================================================

0 commit comments

Comments
 (0)