aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/highlight.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-02-17 15:56:26 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-02-18 17:00:26 -0800
commit99e18d9cef17a9e5ef3b0cefc88c2f8f54c38bf5 (patch)
tree9c6020ebfeb8a40fae4f40ca30c60fefa97ed753 /src/highlight.cpp
parent718d9baead9d900936c9fd6911e387732f706770 (diff)
Remove autosuggest_suggest_special
Diffstat (limited to 'src/highlight.cpp')
-rw-r--r--src/highlight.cpp91
1 files changed, 0 insertions, 91 deletions
diff --git a/src/highlight.cpp b/src/highlight.cpp
index 0272c1fa..da40bfda 100644
--- a/src/highlight.cpp
+++ b/src/highlight.cpp
@@ -480,97 +480,6 @@ static bool autosuggest_parse_command(const wcstring &buff, wcstring *out_expand
return result;
}
-/* We have to return an escaped string here */
-bool autosuggest_suggest_special(const wcstring &str, const env_vars_snapshot_t &vars, completion_t *out_suggestion)
-{
- if (str.empty())
- return false;
-
- ASSERT_IS_BACKGROUND_THREAD();
-
- /* Parse the string */
- wcstring parsed_command;
- parse_node_t last_arg_node(token_type_invalid);
- if (! autosuggest_parse_command(str, &parsed_command, &last_arg_node))
- return false;
-
- 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 1
- std::vector<completion_t> comps;
- complete(str, &comps, COMPLETION_REQUEST_AUTOSUGGESTION, vars);
- 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, &quote, NULL, NULL);
-
- out_suggestion->completion = parse_util_escape_string_with_quote(out_suggestion->completion, quote);
-
- 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;
-
- /* 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;
- out_suggestion->completion.clear();
-
- /* Unescape the parameter */
- wcstring unescaped_dir;
- bool unescaped = unescape_string(escaped_dir, &unescaped_dir, UNESCAPE_INCOMPLETE);
-
- /* Determine the quote type we got from the input directory. */
- wchar_t quote = L'\0';
- parse_util_get_parameter_info(escaped_dir, 0, &quote, NULL, NULL);
-
- /* Big hack to avoid expanding a tilde inside quotes */
- path_flags_t path_flags = (quote == L'\0') ? PATH_EXPAND_TILDE : 0;
- env_var_t working_directory = vars.get(L"PWD");
- if (working_directory.missing_or_empty())
- {
- working_directory = L".";
- }
-
- if (unescaped && is_potential_cd_path(unescaped_dir, working_directory, path_flags, &suggested_path))
- {
- /* Note: this looks really wrong for strings that have an "unescapable" character in them, e.g. a \t, because parse_util_escape_string_with_quote will insert that character */
- wcstring escaped_suggested_path = parse_util_escape_string_with_quote(suggested_path, quote);
-
- /* Return it */
- wcstring suggestion = str;
- suggestion.erase(last_arg_node.source_start);
- if (quote != L'\0') suggestion.push_back(quote);
- suggestion.append(escaped_suggested_path);
- if (quote != L'\0') suggestion.push_back(quote);
- *out_suggestion = completion_t(suggestion, L"", fuzzy_match_exact, COMPLETE_REPLACES_TOKEN);
- }
- }
- else
- {
- /* Either an error or some other command, so we don't handle it specially */
- }
- return result;
-}
-
bool autosuggest_validate_from_history(const history_item_t &item, file_detection_context_t &detector, const wcstring &working_directory, const env_vars_snapshot_t &vars)
{
ASSERT_IS_BACKGROUND_THREAD();