aboutsummaryrefslogtreecommitdiffhomepage
path: root/highlight.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-18 21:56:30 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-18 21:56:30 -0800
commitca1c8243c8beadf1ba985c86237c894aef823b1f (patch)
tree7217a30848f8ed1fb0550942e4aa4485f987dfe2 /highlight.cpp
parent14b3a5be56a99281f2a4c75f7097fd842f922242 (diff)
Fix to prevent autosuggesting cd'ing to the current working directory
Diffstat (limited to 'highlight.cpp')
-rw-r--r--highlight.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/highlight.cpp b/highlight.cpp
index 8f7adf32..55a02913 100644
--- a/highlight.cpp
+++ b/highlight.cpp
@@ -562,9 +562,19 @@ bool autosuggest_handle_special(const wcstring &str, const env_vars &vars, const
/* We can specially handle the cd command */
handled = true;
bool is_help = string_prefixes_string(dir, L"--help") || string_prefixes_string(dir, L"-h");
- if (! is_help && ! path_can_get_cdpath(dir, working_directory.c_str())) {
+ if (is_help) {
suggestionOK = false;
- break;
+ } else {
+ wchar_t *path = path_allocate_cdpath(dir.c_str(), working_directory.c_str());
+ if (path == NULL) {
+ suggestionOK = false;
+ } else if (paths_are_same_file(working_directory, path)) {
+ /* Don't suggest the working directory as the path! */
+ suggestionOK = false;
+ } else {
+ suggestionOK = true;
+ }
+ free(path);
}
}
}