Commit 7985c77326f4850fafadd1d6c1fd0f8bd3e4043e
1 parent
bb89382f
Completion: ignore characters at and after point
Showing
1 changed file
with
5 additions
and
6 deletions
qpdf/qpdf.cc
| @@ -371,7 +371,6 @@ class ArgParser | @@ -371,7 +371,6 @@ class ArgParser | ||
| 371 | std::string bash_prev; | 371 | std::string bash_prev; |
| 372 | std::string bash_cur; | 372 | std::string bash_cur; |
| 373 | std::string bash_line; | 373 | std::string bash_line; |
| 374 | - size_t bash_point; | ||
| 375 | std::set<std::string> completions; | 374 | std::set<std::string> completions; |
| 376 | 375 | ||
| 377 | std::map<std::string, OptionEntry>* option_table; | 376 | std::map<std::string, OptionEntry>* option_table; |
| @@ -390,8 +389,7 @@ ArgParser::ArgParser(int argc, char* argv[], Options& o) : | @@ -390,8 +389,7 @@ ArgParser::ArgParser(int argc, char* argv[], Options& o) : | ||
| 390 | argv(argv), | 389 | argv(argv), |
| 391 | o(o), | 390 | o(o), |
| 392 | cur_arg(0), | 391 | cur_arg(0), |
| 393 | - bash_completion(false), | ||
| 394 | - bash_point(0) | 392 | + bash_completion(false) |
| 395 | { | 393 | { |
| 396 | option_table = &main_option_table; | 394 | option_table = &main_option_table; |
| 397 | initOptionTable(); | 395 | initOptionTable(); |
| @@ -1989,8 +1987,9 @@ ArgParser::checkCompletion() | @@ -1989,8 +1987,9 @@ ArgParser::checkCompletion() | ||
| 1989 | int p = QUtil::string_to_int(bash_point_env.c_str()); | 1987 | int p = QUtil::string_to_int(bash_point_env.c_str()); |
| 1990 | if ((p > 0) && (p <= static_cast<int>(bash_line.length()))) | 1988 | if ((p > 0) && (p <= static_cast<int>(bash_line.length()))) |
| 1991 | { | 1989 | { |
| 1992 | - // Point to the last character | ||
| 1993 | - bash_point = static_cast<size_t>(p) - 1; | 1990 | + // Truncate the line. We ignore everything at or after the |
| 1991 | + // cursor for completion purposes. | ||
| 1992 | + bash_line = bash_line.substr(0, p); | ||
| 1994 | } | 1993 | } |
| 1995 | if (argc >= 4) | 1994 | if (argc >= 4) |
| 1996 | { | 1995 | { |
| @@ -2215,7 +2214,7 @@ ArgParser::handleCompletion() | @@ -2215,7 +2214,7 @@ ArgParser::handleCompletion() | ||
| 2215 | if (bash_cur.empty() && (bash_prev.length() > 2) && | 2214 | if (bash_cur.empty() && (bash_prev.length() > 2) && |
| 2216 | (bash_prev.at(0) == '-') && | 2215 | (bash_prev.at(0) == '-') && |
| 2217 | (bash_prev.at(1) == '-') && | 2216 | (bash_prev.at(1) == '-') && |
| 2218 | - (bash_line.at(bash_point) == '=')) | 2217 | + (bash_line.at(bash_line.length() - 1) == '=')) |
| 2219 | { | 2218 | { |
| 2220 | choice_option = bash_prev.substr(2, std::string::npos); | 2219 | choice_option = bash_prev.substr(2, std::string::npos); |
| 2221 | } | 2220 | } |