Skip to content

Commit 4ba0775

Browse files
committed
feat: always show bookmark gutter, prepare for code folding, fix font loading
1 parent 58e051d commit 4ba0775

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/editor_app.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ void EditorApp::load_fonts() {
788788
// Fallback to default
789789
if (!font) {
790790
font = io.Fonts->AddFontDefault();
791+
// Clear font name since we couldn't load the requested one
792+
settings_.font_name = "";
791793
}
792794

793795
font_size_temp_ = settings_.font_size;
@@ -802,28 +804,34 @@ void EditorApp::rebuild_fonts() {
802804

803805
// Update font size
804806
settings_.font_size = font_size_temp_;
805-
settings_.font_name = font_name_temp_;
806807

807808
// Clear and rebuild fonts
808809
io.Fonts->Clear();
809810

810811
ImFont* font = nullptr;
811812

812813
// Try to load user-selected font
813-
if (!settings_.font_name.empty()) {
814+
if (!font_name_temp_.empty()) {
814815
#ifdef _WIN32
815816
std::vector<std::string> exts = {".ttc", ".ttf", ".otf"};
816817
for (const auto& ext : exts) {
817-
std::string path = "C:/Windows/Fonts/" + settings_.font_name + ext;
818+
std::string path = "C:/Windows/Fonts/" + font_name_temp_ + ext;
818819
font = io.Fonts->AddFontFromFileTTF(path.c_str(), (float)settings_.font_size);
819-
if (font) break;
820+
if (font) {
821+
// Success - update settings with the loaded font name
822+
settings_.font_name = font_name_temp_;
823+
break;
824+
}
820825
}
821826
#endif
822827
}
823828

824-
// Fallback to default
829+
// Fallback to default if couldn't load
825830
if (!font) {
826831
font = io.Fonts->AddFontDefault();
832+
// Clear - couldn't load the requested font
833+
font_name_temp_ = "";
834+
settings_.font_name = "";
827835
}
828836

829837
float scale = (float)settings_.font_size / 16.0f;
@@ -1151,8 +1159,9 @@ void EditorApp::render_editor_with_margins() {
11511159
auto& tab = tabs_[active_tab_];
11521160
TextEditor* editor = tab.editor;
11531161

1154-
// Show custom gutter only for bookmarks and change history (not line numbers - TextEditor handles that)
1155-
bool has_bookmarks = !tab.bookmarks.empty();
1162+
// Always show gutter for bookmarks (allows adding/removing bookmarks)
1163+
// Also show change history when there are changes
1164+
bool has_bookmarks = true; // Always show bookmark gutter
11561165
bool has_changes = !tab.changed_lines.empty();
11571166

11581167
if (has_bookmarks || has_changes) {
@@ -1169,7 +1178,7 @@ void EditorApp::render_editor_with_margins() {
11691178
for (int line = 0; line < total_lines; line++) {
11701179
ImGui::PushID(line);
11711180

1172-
// Bookmark column
1181+
// Bookmark column - clickable to toggle
11731182
bool is_bookmarked = std::find(tab.bookmarks.begin(), tab.bookmarks.end(), line) != tab.bookmarks.end();
11741183
if (is_bookmarked) {
11751184
ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), ""); // Checkmark symbol

0 commit comments

Comments
 (0)