From b4b3a82ee32732fa250cd76cefceb2db644fce59 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Fri, 10 Jun 2016 13:19:30 -0600 Subject: [PATCH] Fix #168 and #130: Escape tildes when fetching suggestions --- src/suggestion.zsh | 2 +- test/strategies_test.zsh | 7 +++++++ zsh-autosuggestions.zsh | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/suggestion.zsh b/src/suggestion.zsh index 0a7ca1e..31a9f76 100644 --- a/src/suggestion.zsh +++ b/src/suggestion.zsh @@ -17,5 +17,5 @@ _zsh_autosuggest_escape_command() { setopt localoptions EXTENDED_GLOB # Escape special chars in the string (requires EXTENDED_GLOB) - echo -E "${1//(#m)[\\()\[\]|*?]/\\$MATCH}" + echo -E "${1//(#m)[\\()\[\]|*?~]/\\$MATCH}" } diff --git a/test/strategies_test.zsh b/test/strategies_test.zsh index 50d0a24..0a937f4 100644 --- a/test/strategies_test.zsh +++ b/test/strategies_test.zsh @@ -44,6 +44,12 @@ assertTildeSuggestion() { 'cd ~/something' } +assertTildeSuggestionWithExtendedGlob() { + setopt local_options extended_glob + + assertTildeSuggestion +} + assertParenthesesSuggestion() { set_history <<-'EOF' echo "$(ls foo)" @@ -87,6 +93,7 @@ testSpecialCharsForAllStrategies() { assertBackslashSuggestion assertDoubleBackslashSuggestion assertTildeSuggestion + assertTildeSuggestionWithExtendedGlob assertParenthesesSuggestion assertSquareBracketsSuggestion done diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 7e44a77..d2c7d2c 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -360,7 +360,7 @@ _zsh_autosuggest_escape_command() { setopt localoptions EXTENDED_GLOB # Escape special chars in the string (requires EXTENDED_GLOB) - echo -E "${1//(#m)[\\()\[\]|*?]/\\$MATCH}" + echo -E "${1//(#m)[\\()\[\]|*?~]/\\$MATCH}" } #--------------------------------------------------------------------#