diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-12-22 15:33:03 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-12-22 17:42:37 +0100 |
commit | 7985c77326f4850fafadd1d6c1fd0f8bd3e4043e (patch) | |
tree | ef67886a204f798adb3a6babc7b0e37b83a68b5d | |
parent | bb89382f936fa373eb7ec6708d83e5713cada644 (diff) | |
download | qpdf-7985c77326f4850fafadd1d6c1fd0f8bd3e4043e.tar.zst |
Completion: ignore characters at and after point
-rw-r--r-- | qpdf/qpdf.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index c86cb2a4..8c195373 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -371,7 +371,6 @@ class ArgParser std::string bash_prev; std::string bash_cur; std::string bash_line; - size_t bash_point; std::set<std::string> completions; std::map<std::string, OptionEntry>* option_table; @@ -390,8 +389,7 @@ ArgParser::ArgParser(int argc, char* argv[], Options& o) : argv(argv), o(o), cur_arg(0), - bash_completion(false), - bash_point(0) + bash_completion(false) { option_table = &main_option_table; initOptionTable(); @@ -1989,8 +1987,9 @@ ArgParser::checkCompletion() int p = QUtil::string_to_int(bash_point_env.c_str()); if ((p > 0) && (p <= static_cast<int>(bash_line.length()))) { - // Point to the last character - bash_point = static_cast<size_t>(p) - 1; + // Truncate the line. We ignore everything at or after the + // cursor for completion purposes. + bash_line = bash_line.substr(0, p); } if (argc >= 4) { @@ -2215,7 +2214,7 @@ ArgParser::handleCompletion() if (bash_cur.empty() && (bash_prev.length() > 2) && (bash_prev.at(0) == '-') && (bash_prev.at(1) == '-') && - (bash_line.at(bash_point) == '=')) + (bash_line.at(bash_line.length() - 1) == '=')) { choice_option = bash_prev.substr(2, std::string::npos); } |