Correctly complete redirections. Fixes #1296

This commit is contained in:
ridiculousfish 2014-05-02 01:22:39 -07:00
parent 0c4819131c
commit 16b982958b
2 changed files with 34 additions and 20 deletions

View file

@ -1977,8 +1977,21 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps
}
}
bool do_file = false;
/* If we are not in an argument, we may be in a redirection */
bool in_redirection = false;
if (matching_arg_index == (size_t)(-1))
{
const parse_node_t *redirection = tree.find_node_matching_source_location(symbol_redirection, pos, plain_statement);
in_redirection = (redirection != NULL);
}
bool do_file = false;
if (in_redirection)
{
do_file = true;
}
else
{
wcstring current_command_unescape, previous_argument_unescape, current_argument_unescape;
if (unescape_string(current_command, &current_command_unescape, UNESCAPE_DEFAULT) &&
unescape_string(previous_argument, &previous_argument_unescape, UNESCAPE_DEFAULT) &&
@ -1999,6 +2012,7 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps
{
do_file = false;
}
}
/* This function wants the unescaped string */
completer.complete_param_expand(current_token, do_file);

View file

@ -1351,7 +1351,7 @@ const parse_node_t *parse_node_tree_t::find_node_matching_source_location(parse_
continue;
/* If a parent is given, it must be an ancestor */
if (parent != NULL && node_has_ancestor(*this, node, *parent))
if (parent != NULL && ! node_has_ancestor(*this, node, *parent))
continue;
/* Found it */