diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index fab54bca..227a75eb 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -737,7 +737,11 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { ) { if (ImGui::Button("save to")) { _fss.requestFile( - [](const auto& path) -> bool { return std::filesystem::is_directory(path); }, + [](std::filesystem::path& path) -> bool { + // remove file path + path.remove_filename(); + return std::filesystem::is_directory(path); + }, [this, ®, e](const auto& path) { if (reg.valid(e)) { // still valid // TODO: trim file? diff --git a/src/file_selector.cpp b/src/file_selector.cpp index cc5a7d24..05ca9c04 100644 --- a/src/file_selector.cpp +++ b/src/file_selector.cpp @@ -18,7 +18,7 @@ FileSelector::FileSelector(void) { } void FileSelector::requestFile( - std::function&& is_valid, + std::function&& is_valid, std::function&& on_choose, std::function&& on_cancel ) { @@ -77,7 +77,9 @@ void FileSelector::render(void) { if (current_path.has_parent_path()) { if (ImGui::TableNextColumn()) { if (ImGui::Selectable("D##..", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap)) { - _current_file_path = _current_file_path.parent_path(); + // the first "parent_path()" only removes the filename and the ending "/" + _current_file_path = _current_file_path.parent_path().parent_path() / ""; + //_current_file_path = _current_file_path.remove_filename().parent_path() / ""; } } diff --git a/src/file_selector.hpp b/src/file_selector.hpp index 2a783a99..33620bff 100644 --- a/src/file_selector.hpp +++ b/src/file_selector.hpp @@ -8,7 +8,7 @@ struct FileSelector { bool _open_popup {false}; - std::function _is_valid = [](auto){ return true; }; + std::function _is_valid = [](auto){ return true; }; std::function _on_choose = [](auto){}; std::function _on_cancel = [](){}; @@ -18,8 +18,9 @@ struct FileSelector { FileSelector(void); // TODO: supply hints + // HACK: until we supply hints, is_valid can modify void requestFile( - std::function&& is_valid, + std::function&& is_valid, std::function&& on_choose, std::function&& on_cancel );