diff --git a/bash-pinyin-completion.cpp b/bash-pinyin-completion.cpp index 4e18d70..e28078b 100644 --- a/bash-pinyin-completion.cpp +++ b/bash-pinyin-completion.cpp @@ -121,8 +121,11 @@ int main(int argc, char **argv) { input = home + input; } auto split = split_string(input, '/'); - auto final = split.back(); - if (input.back() != '/') { + string final; + if (input.back() == '/') { + final = ""; + } else { + final = split.back(); split.pop_back(); } auto pinyin = string_pinyin(final); @@ -130,7 +133,7 @@ int main(int argc, char **argv) { // Navigate to the dir we need to complete auto dest = filesystem::path(input.c_str()).parent_path(); if (!dest.empty()) { - if (!filesystem::exists(dest)) { + if (!filesystem::exists(dest) || !filesystem::is_directory(dest)) { return 0; } filesystem::current_path(dest); @@ -139,6 +142,7 @@ int main(int argc, char **argv) { auto compreply = split_string(run_command("/usr/bin/env bash -c \"compgen " + compgen_opts + "\""), '\n'); for (auto reply : compreply) { auto reply_pinyin = string_pinyin(reply); + if (reply_pinyin == reply) continue; if (reply_pinyin.compare(0, pinyin.size(), pinyin) == 0) { for (auto substr : split) { cout << substr << "/"; diff --git a/debian/changelog b/debian/changelog index 7f52c9e..5cff5e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,14 @@ +bash-pinyin-completion (0.0.3) unstable; urgency=medium + + * fix sshfs command tab shows multiple home. + + -- lichenggang Wed, 09 Jul 2025 10:44:25 +0800 + bash-pinyin-completion (0.0.2) unstable; urgency=medium - * Fix completion exception. + * Move logic to C++, fix several issues - -- lichenggang Thu, 03 Jul 2025 14:31:32 +0800 + -- April Lu Wed, 09 Jul 2025 10:10:00 +0800 bash-pinyin-completion (0.0.1) unstable; urgency=medium diff --git a/debian/control b/debian/control index 2e5ef91..a979a2a 100644 --- a/debian/control +++ b/debian/control @@ -1,10 +1,10 @@ Source: bash-pinyin-completion Section: shells Priority: optional -Maintainer: Deepin Packages Builder +Maintainer: April Lu Build-Depends: debhelper-compat (= 13) Standards-Version: 4.7.2.0 -Homepage: https://github.com/apr3vau/bash-pinyin-completion-cpp +Homepage: https://github.com/calsym456/bash-pinyin-completion-cpp Package: bash-pinyin-completion Architecture: any diff --git a/scripts/bash_pinyin_completion b/scripts/bash_pinyin_completion index 2a0ac88..c496262 100644 --- a/scripts/bash_pinyin_completion +++ b/scripts/bash_pinyin_completion @@ -61,7 +61,14 @@ _pinyin_completion() { # Main part local -a pinyin_matched - readarray -t pinyin_matched < <(bash-pinyin-completion "$cur" "$compgen_opts") + if [[ "${compgen_opts[0]}" == -d ]]; then + readarray -t pinyin_matched < <(bash-pinyin-completion "$cur" "-d") + else + readarray -t pinyin_matched < <(bash-pinyin-completion "$cur" "-f") + if [ ${#pinyin_matched[@]} -ne 0 ]; then + compopt -o filenames 2>/dev/null + fi + fi # merge result local -a old_candidates=("${COMPREPLY[@]}") diff --git a/test.sh b/test.sh deleted file mode 100644 index 8920c8b..0000000 --- a/test.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -mkdir -p "测试" -correct=0 -if [[ $(./bash-pinyin-completion ce -f) == "测试" ]]; then - echo "Test 1 PASSED" - ((correct += 1)) -else - echo "Test 1 NOT PASSED" -fi - -if [[ $(./bash-pinyin-completion ./ce -f) == "./测试" ]]; then - echo "Test 2 PASSED" - ((correct += 1)) -else - echo "Test 2 NOT PASSED" -fi - -if [[ $(wc -l <<<"$(./bash-pinyin-completion /usr/lib -f)" | xargs) == 2 ]]; then - echo "Test 3 PASSED" - ((correct += 1)) -else - echo "Test 3 NOT PASSED" -fi - -if [[ $(wc -l <<<"$(./bash-pinyin-completion /usr/lib/ -f)" | xargs) -gt 3 ]]; then - echo "Test 4 PASSED" - ((correct += 1)) -else - echo "Test 4 NOT PASSED" -fi - -rm -r "测试" -if [[ correct -lt 4 ]]; then - exit 1 -fi - -exit 0