From 345a52862587210477f8e5a9a41c21c26a265009 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 6 Jul 2012 14:34:53 -0700 Subject: Untangle unescaping responsibilities in highlight.cpp. Fix cd autosuggestions to properly handle quotes. Factor out some of the quote unescaping behavior from reader.cpp to parse_util.cpp. Add some autosuggestion tests --- highlight.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'highlight.h') diff --git a/highlight.h b/highlight.h index 339929cf..7e30fe08 100644 --- a/highlight.h +++ b/highlight.h @@ -114,7 +114,7 @@ rgb_color_t highlight_get_color( int 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 &vars); -/** Given the command line contents 'str', return via reference a suggestion by specially recognizing the command. Returns true if we recognized the command (even if we couldn't think of a suggestion for it). +/** 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). */ bool autosuggest_suggest_special(const wcstring &str, const wcstring &working_directory, wcstring &outString); @@ -122,7 +122,15 @@ bool autosuggest_suggest_special(const wcstring &str, const wcstring &working_di This is used only internally to this file, and is exposed only for testing. */ -bool is_potential_path(const wcstring &const_path, const wcstring_list_t &directories, bool require_dir = false, wcstring *out_path = NULL); +enum { + /* The path must be to a directory */ + PATH_REQUIRE_DIR = 1 << 0, + + /* Expand any leading tilde in the path */ + PATH_EXPAND_TILDE = 1 << 1 +}; +typedef unsigned int path_flags_t; +bool is_potential_path(const wcstring &const_path, const wcstring_list_t &directories, path_flags_t flags, wcstring *out_path = NULL); #endif -- cgit v1.2.3