From a14afced4fb2fbbd2d0c64564af911777b874c0c Mon Sep 17 00:00:00 2001 From: YamaD Date: Sat, 18 Oct 2025 17:40:39 +0900 Subject: [PATCH] fix SkkEngine::loadDictionary() envvar behavior --- src/skk.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/skk.cpp b/src/skk.cpp index e09a942..f98421d 100644 --- a/src/skk.cpp +++ b/src/skk.cpp @@ -534,13 +534,20 @@ void SkkEngine::loadDictionary() { if (path.empty() || mode == 0) { continue; } + + std::string_view partialpath = path; + if (stringutils::consumePrefix(partialpath, + "$FCITX_CONFIG_DIR/")) { + path = StandardPaths::global().userDirectory( + StandardPathsType::PkgData) / + partialpath; + } else if (stringutils::consumePrefix(partialpath, + "$XDG_DATA_DIRS/")) { + path = StandardPaths::global().locate( + StandardPathsType::Data, partialpath); + } + if (mode == 1) { - std::string_view partialpath = path; - if (stringutils::consumePrefix(partialpath, - "$XDG_DATA_DIRS/")) { - path = StandardPaths::global().locate( - StandardPathsType::Data, partialpath); - } if (stringutils::endsWith(path, ".cdb")) { SkkCdbDict *dict = skk_cdb_dict_new(path.data(), encoding.data(), nullptr); @@ -557,13 +564,6 @@ void SkkEngine::loadDictionary() { } } } else { - std::string_view partialpath = path; - if (stringutils::consumePrefix(partialpath, - "$FCITX_CONFIG_DIR/")) { - path = StandardPaths::global().userDirectory( - StandardPathsType::PkgData) / - partialpath; - } SkkUserDict *userdict = skk_user_dict_new(path.data(), encoding.data(), nullptr); if (userdict) {