Change Bash completion code for dirs/files to new coding style
This commit is contained in:
parent
6f924da4f0
commit
f97320816a
|
@ -1527,13 +1527,13 @@ void ArgumentParser::printBashCompletion(int argc, const char *const *argv, unsi
|
||||||
}
|
}
|
||||||
// -> completions for files and dirs
|
// -> completions for files and dirs
|
||||||
// -> if there's already an "opening", determine the dir part and the file part
|
// -> if there's already an "opening", determine the dir part and the file part
|
||||||
string actualDir, actualFile;
|
auto actualDir = std::string(), actualFile = std::string();
|
||||||
bool haveFileOrDirCompletions = false;
|
auto haveFileOrDirCompletions = false;
|
||||||
if (argc && currentWordIndex == completionInfo.lastSpecifiedArgIndex && opening) {
|
if (argc && currentWordIndex == completionInfo.lastSpecifiedArgIndex && opening) {
|
||||||
// the "opening" might contain escaped characters which need to be unescaped first
|
// the "opening" might contain escaped characters which need to be unescaped first
|
||||||
const auto unescapedOpening = unescape(opening);
|
const auto unescapedOpening = unescape(opening);
|
||||||
// determine the "directory" part
|
// determine the "directory" part
|
||||||
string dir = directory(unescapedOpening);
|
auto dir = directory(unescapedOpening);
|
||||||
if (dir.empty()) {
|
if (dir.empty()) {
|
||||||
actualDir = ".";
|
actualDir = ".";
|
||||||
} else {
|
} else {
|
||||||
|
@ -1546,7 +1546,7 @@ void ArgumentParser::printBashCompletion(int argc, const char *const *argv, unsi
|
||||||
actualDir = std::move(dir);
|
actualDir = std::move(dir);
|
||||||
}
|
}
|
||||||
// determine the "file" part
|
// determine the "file" part
|
||||||
string file = fileName(unescapedOpening);
|
auto file = fileName(unescapedOpening);
|
||||||
if (file[0] == '\"' || file[0] == '\'') {
|
if (file[0] == '\"' || file[0] == '\'') {
|
||||||
file.erase(0, 1);
|
file.erase(0, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue