aboutsummaryrefslogtreecommitdiffhomepage
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
parent718d9baead9d900936c9fd6911e387732f706770 (diff)
Remove autosuggest_suggest_special
-rw-r--r--src/complete.cpp2
-rw-r--r--src/highlight.cpp91
-rw-r--r--src/highlight.h5
-rw-r--r--src/reader.cpp12
4 files changed, 1 insertions, 109 deletions
diff --git a/src/complete.cpp b/src/complete.cpp
index 0a173a79..4c157778 100644
--- a/src/complete.cpp
+++ b/src/complete.cpp
@@ -1388,7 +1388,7 @@ void completer_t::complete_param_expand(const wcstring &str, bool do_file, bool
if (handle_as_special_cd && do_file)
{
- flags |= DIRECTORIES_ONLY | EXPAND_SPECIAL_CD;
+ flags |= DIRECTORIES_ONLY | EXPAND_SPECIAL_CD | EXPAND_NO_DESCRIPTIONS;
}
/* Squelch file descriptions per issue 254 */
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();
diff --git a/src/highlight.h b/src/highlight.h
index 4bd0e4a0..22021ba1 100644
--- a/src/highlight.h
+++ b/src/highlight.h
@@ -113,11 +113,6 @@ rgb_color_t highlight_get_color(highlight_spec_t highlight, bool is_background);
*/
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);
-/** Given the command line contents 'str', return via reference a suggestion by specially recognizing the command. The suggestion is escaped. Returns true if we recognized the command (even if we couldn't think of a suggestion for it).
-*/
-class completion_t;
-bool autosuggest_suggest_special(const wcstring &str, const env_vars_snapshot_t &vars, completion_t *out_suggestion);
-
/* Tests whether the specified string cpath is the prefix of anything we could cd to. directories is a list of possible parent directories (typically either the working directory, or the cdpath). This does I/O!
This is used only internally to this file, and is exposed only for testing.
diff --git a/src/reader.cpp b/src/reader.cpp
index 08f84930..81bdefb8 100644
--- a/src/reader.cpp
+++ b/src/reader.cpp
@@ -1479,18 +1479,6 @@ struct autosuggestion_context_t
if (reader_thread_job_is_stale())
return 0;
- /* Try handling a special command like cd */
- completion_t special_suggestion(L"");
- if (autosuggest_suggest_special(search_string, this->vars, &special_suggestion))
- {
- this->autosuggestion = special_suggestion.completion;
- return 1;
- }
-
- /* Maybe cancel here */
- if (reader_thread_job_is_stale())
- return 0;
-
// Here we do something a little funny
// If the line ends with a space, and the cursor is not at the end,
// don't use completion autosuggestions. It ends up being pretty weird seeing stuff get spammed on the right