Diff
1diff --git a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
2index f8c49bfac019be65fe66524dcbceadc04fa2c8aa..7ed7828ea4f352a13c959f2e0a25e9f6cd04fb89 100644
3--- a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
4+++ b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
5@@ -1,4 +1,5 @@
6 # Hotlist
7+# Try to use $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions
8 local hotlist
9 hotlist=(
10 ~/.config/znt
11@@ -7,7 +8,6 @@ hotlist=(
12 /usr/local/share/zsh/site-functions
13 /usr/local/share/zsh
14 /usr/local/bin
15- /usr/lib
16 )
17
18 # Suppress adding (to directory stack) directories visited by n-cd
19diff --git a/plugins/zsh-navigation-tools/README.md b/plugins/zsh-navigation-tools/README.md
20index 4420dab829b2754b3a5270746327a28f83916502..32a86bba91d0b7e7fa49a87584b7c3cd32d049b8 100644
21--- a/plugins/zsh-navigation-tools/README.md
22+++ b/plugins/zsh-navigation-tools/README.md
23@@ -25,7 +25,7 @@ widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned
24 to key combinations (no need for autoload when using Oh My Zsh):
25
26 zle -N znt-cd-widget
27- bindkey "^T" znt-cd-widget
28+ bindkey "^A" znt-cd-widget
29 zle -N znt-kill-widget
30 bindkey "^Y" znt-kill-widget
31
32diff --git a/plugins/zsh-navigation-tools/n-history b/plugins/zsh-navigation-tools/n-history
33index c9e53316beb5e0995bf22ea4134a2d7d82476e6f..9f1d6279ba62a8ab6b125be68d78948fe9345747 100644
34--- a/plugins/zsh-navigation-tools/n-history
35+++ b/plugins/zsh-navigation-tools/n-history
36@@ -42,7 +42,7 @@ if [ "$REPLY" -gt 0 ]; then
37 # ZLE?
38 if [ "${(t)CURSOR}" = "integer-local-special" ]; then
39 zle redisplay
40- zle kill-whole-line
41+ zle kill-buffer
42 zle -U "$selected"
43 else
44 print -zr "$selected"
45diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list
46index 388712bd0ee6c32b44aced358c3c20047e3bfa60..50159b4a016ee6cc2d14fefae98defc743910b12 100644
47--- a/plugins/zsh-navigation-tools/n-list
48+++ b/plugins/zsh-navigation-tools/n-list
49@@ -1,6 +1,7 @@
50 # $1, $2, ... - elements of the list
51 # $NLIST_NONSELECTABLE_ELEMENTS - array of indexes (1-based) that cannot be selected
52 # $REPLY is the output variable - contains index (1-based) or -1 when no selection
53+# $reply (array) is the second part of the output - use the index (REPLY) to get selected element
54 #
55 # Copy this file into /usr/share/zsh/site-functions/
56 # and add 'autoload n-list` to .zshrc
57@@ -164,6 +165,7 @@ integer current_difference=0
58 local prev_search_buffer=""
59 integer prev_uniq_mode=0
60 integer prev_start_idx=-1
61+local MBEGIN MEND MATCH mbegin mend match
62
63 # Ability to remember the list between calls
64 if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then
65@@ -264,11 +266,15 @@ while (( 1 )); do
66 local search_pattern=""
67 local colsearch_pattern=""
68 if [ -n "$search_buffer" ]; then
69- # Patterns will be *foo*~^*bar* and foo|bar)
70+ # Patterns will be *foo*~^*bar* and (foo|bar)
71 search_pattern="${search_buffer// ##/*~^*}"
72 colsearch_pattern="${search_buffer// ##/|}"
73
74- list=( "${(@M)list:#(#i)*$~search_pattern*}" )
75+ # The repeat will make the matching work on a fresh heap
76+ repeat 1; do
77+ list=( "${(@M)list:#(#i)*$~search_pattern*}" )
78+ done
79+
80 last_element="$#list"
81 fi
82
83@@ -287,7 +293,10 @@ while (( 1 )); do
84
85 if [ -n "$colsearch_pattern" ]; then
86 local red=$'\x1b[00;31m' reset=$'\x1b[00;00m'
87- disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
88+ # The repeat will make the matching work on a fresh heap
89+ repeat 1; do
90+ disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
91+ done
92 fi
93
94 # We have display list, lets replace newlines with "\n" when needed (1/2)
95@@ -380,7 +389,7 @@ while (( 1 )); do
96
97 # Get the special (i.e. "keypad") key or regular key
98 if [ -n "$key" ]; then
99- final_key="$key"
100+ final_key="$key"
101 elif [ -n "$keypad" ]; then
102 final_key="$keypad"
103 else
104diff --git a/plugins/zsh-navigation-tools/n-list-draw b/plugins/zsh-navigation-tools/n-list-draw
105index 1b2571fbd42f0930f47717138bc9a21c14781cd5..2f8b1d0d5838a29c6bd264633ec06ed52090e081 100644
106--- a/plugins/zsh-navigation-tools/n-list-draw
107+++ b/plugins/zsh-navigation-tools/n-list-draw
108@@ -98,7 +98,7 @@ shift 7
109 integer max_text_len=page_width-x_offset
110
111 [ "$bold" = "0" ] && bold="" || bold="+bold"
112-[[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || active_text="reverse"
113+[[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || local active_text="reverse"
114 # With Linux terminal underline won't work properly
115 [ "$TERM" = "linux" ] && active_text="reverse"
116
117diff --git a/plugins/zsh-navigation-tools/n-list-input b/plugins/zsh-navigation-tools/n-list-input
118index 380acdc00aeedcf3b14b4a67e7bb2dae7a116ad6..957cd5a0b134f5984d2124c52b8d564e219f2f1f 100644
119--- a/plugins/zsh-navigation-tools/n-list-input
120+++ b/plugins/zsh-navigation-tools/n-list-input
121@@ -44,7 +44,7 @@ case "$key" in
122 [ "$current_idx" -lt "$last_element" ] && current_idx=current_idx+1;
123 _nlist_compute_first_to_show_idx
124 ;;
125- (PPAGE)
126+ (PPAGE|$'\b'|$'\C-?'|BACKSPACE)
127 current_idx=current_idx-page_height
128 [ "$current_idx" -lt 1 ] && current_idx=1;
129 _nlist_compute_first_to_show_idx
130@@ -72,7 +72,7 @@ case "$key" in
131 current_idx=last_element
132 _nlist_compute_first_to_show_idx
133 ;;
134- ($'\n')
135+ ($'\n'|ENTER)
136 # Is that element selectable?
137 # Check for this only when there is no search
138 if [[ "$NLIST_SEARCH_BUFFER" != "" || "$NLIST_IS_UNIQ_MODE" -eq 1 ||
139@@ -137,7 +137,7 @@ esac
140 else
141
142 case "$key" in
143- ($'\n')
144+ ($'\n'|ENTER)
145 search=0
146 _nlist_cursor_visibility 0
147 ;;
148diff --git a/plugins/zsh-navigation-tools/znt-history-widget b/plugins/zsh-navigation-tools/znt-history-widget
149index 9ddae606d9163f7e4b61f048909fcd3854919698..a4a26cbfcb6005759584abfe019c6b908c1be647 100644
150--- a/plugins/zsh-navigation-tools/znt-history-widget
151+++ b/plugins/zsh-navigation-tools/znt-history-widget
152@@ -1,7 +1,11 @@
153 autoload znt-usetty-wrapper n-history
154 local NLIST_START_IN_SEARCH_MODE=1
155 local NLIST_START_IN_UNIQ_MODE=1
156-local NLIST_SET_SEARCH_TO="$BUFFER"
157+
158+# Only if current $BUFFER doesn't come from history
159+if [ "$HISTCMD" = "$HISTNO" ]; then
160+ local NLIST_SET_SEARCH_TO="$BUFFER"
161+fi
162
163 znt-usetty-wrapper n-history "$@"
164