From 9a5206ebf95dbf72f7a84df893cabc896f9e3194 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 5 Jan 2023 19:12:44 +0300 Subject: [PATCH] Fix file dialog on windows --- libs/ui/source/file_dialog.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/ui/source/file_dialog.cpp b/libs/ui/source/file_dialog.cpp index 0c20393a..6e995f5b 100644 --- a/libs/ui/source/file_dialog.cpp +++ b/libs/ui/source/file_dialog.cpp @@ -110,6 +110,7 @@ namespace psemek::ui std::string escape(std::string str) { + str = replace(std::move(str), "\\", "\\\\"); str = replace(std::move(str), "[", "\\["); str = replace(std::move(str), "]", "\\]"); return str; @@ -233,10 +234,12 @@ namespace psemek::ui int index = 0; for (auto const & component : new_path) { - if (component.string() != "/") - path_str += "[link:" + util::to_string(++index) + "]" + escape(component.string()) + "[/link]/"; - else - path_str += "[link:" + util::to_string(++index) + "]" + escape(component.string()) + "[/link]"; + if (!new_path.root_name().empty() && component == new_path.root_directory()) + continue; + + path_str += "[link:" + util::to_string(++index) + "]" + escape(component.string()) + "[/link]"; + if (!new_path.root_name().empty() || component != new_path.root_directory()) + path_str += escape(std::string(1, char(std::filesystem::path::preferred_separator))); } current_path_label->set_tagged_text(std::move(path_str));