Fix Bash completion for dirs when not using actual dir

This commit is contained in:
Martchus 2019-09-04 18:26:37 +02:00
parent 03fdc62dce
commit 43d2d280e1
2 changed files with 6 additions and 1 deletions

View File

@ -113,7 +113,7 @@ set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parse
set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local)
set(META_VERSION_MAJOR 5)
set(META_VERSION_MINOR 0)
set(META_VERSION_PATCH 0)
set(META_VERSION_PATCH 1)
# find required 3rd party libraries
include(3rdParty)

View File

@ -1521,16 +1521,21 @@ void ArgumentParser::printBashCompletion(int argc, const char *const *argv, unsi
continue;
}
auto dirEntryName = dirEntry.path().filename().string();
auto hasStartingQuote = false;
if (useActualDir) {
if (!startsWith(dirEntryName, actualFile)) {
continue;
}
cout << '\'';
hasStartingQuote = true;
if (actualDir != ".") {
cout << actualDir;
}
}
findAndReplace(dirEntryName, replace, with);
if (!hasStartingQuote) {
cout << '\'';
}
cout << dirEntryName << '\'' << ' ';
haveFileOrDirCompletions = true;
}