From c39b94949be30dfbc1c3e271b37ca04cff303b16 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 6 Feb 2016 19:17:43 -0800 Subject: Complete to take a pointer to output completions, not a mutable ref --- src/highlight.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/highlight.cpp') diff --git a/src/highlight.cpp b/src/highlight.cpp index 4e5dc3f3..595631b7 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -26,6 +26,7 @@ #include "env.h" #include "expand.h" #include "common.h" +#include "complete.h" #include "output.h" #include "wildcard.h" #include "path.h" @@ -496,6 +497,33 @@ bool autosuggest_suggest_special(const wcstring &str, const wcstring &working_di bool result = false; if (parsed_command == L"cd" && last_arg_node.type == symbol_argument && last_arg_node.has_source()) { + + /* We always return true because we recognized the command. This prevents us from falling back to dumber algorithms; for example we won't suggest a non-directory for the cd command. */ + result = true; +#if 0 + std::vector comps; + complete(str, &comps, COMPLETION_REQUEST_AUTOSUGGESTION); + if (! comps.empty()) + { + *out_suggestion = comps.at(0); + } + + // Hackish to make tests pass + if (!(out_suggestion->flags & COMPLETE_REPLACES_TOKEN)) + { + out_suggestion->completion.insert(0, str); + out_suggestion->flags |= COMPLETE_REPLACES_TOKEN; + + wcstring escaped_dir = last_arg_node.get_source(str); + wchar_t quote = L'\0'; + parse_util_get_parameter_info(escaped_dir, 0, "e, NULL, NULL); + if (quote != L'\0') out_suggestion->completion.push_back(quote); + } + + return result; +#endif + + /* We can possibly handle this specially */ const wcstring escaped_dir = last_arg_node.get_source(str); wcstring suggested_path; -- cgit v1.2.3