##// END OF EJS Templates
bash_completion: fix issue with subdirectories not being completed...
Sean Farley -
r20126:25cb1d96 default
parent child Browse files
Show More
@@ -84,7 +84,6 b' shopt -s extglob'
84 84 {
85 85 local files="$(_hg_cmd debugpathcomplete $1 "$cur")"
86 86 local IFS=$'\n'
87 compopt -o filenames 2>/dev/null
88 87 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
89 88 }
90 89
@@ -92,7 +91,6 b' shopt -s extglob'
92 91 {
93 92 local files="$(_hg_cmd status -n$1 "glob:$cur**")"
94 93 local IFS=$'\n'
95 compopt -o filenames 2>/dev/null
96 94 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
97 95 }
98 96
@@ -128,6 +126,19 b' shopt -s extglob'
128 126 echo $(($count - 1))
129 127 }
130 128
129 _hg_fix_wordlist()
130 {
131 local LASTCHAR=' '
132 if [ ${#COMPREPLY[@]} = 1 ]; then
133 [ -d "$COMPREPLY" ] && LASTCHAR=/
134 COMPREPLY=$(printf %q%s "$COMPREPLY" "$LASTCHAR")
135 else
136 for ((i=0; i < ${#COMPREPLY[@]}; i++)); do
137 [ -d "${COMPREPLY[$i]}" ] && COMPREPLY[$i]=${COMPREPLY[$i]}/
138 done
139 fi
140 }
141
131 142 _hg()
132 143 {
133 144 local cur prev cmd cmd_index opts i aliashg
@@ -162,12 +173,14 b' shopt -s extglob'
162 173
163 174 if [[ "$cur" == -* ]]; then
164 175 if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then
176 _hg_fix_wordlist
165 177 return
166 178 fi
167 179
168 180 opts=$(_hg_cmd debugcomplete --options "$cmd")
169 181
170 182 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
183 _hg_fix_wordlist
171 184 return
172 185 fi
173 186
@@ -176,22 +189,26 b' shopt -s extglob'
176 189 -R|--repository)
177 190 _hg_paths
178 191 _hg_repos
192 _hg_fix_wordlist
179 193 return
180 194 ;;
181 195 --cwd)
182 196 # Stick with default bash completion
197 _hg_fix_wordlist
183 198 return
184 199 ;;
185 200 esac
186 201
187 202 if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
188 203 _hg_commands
204 _hg_fix_wordlist
189 205 return
190 206 fi
191 207
192 208 # try to generate completion candidates for whatever command the user typed
193 209 local help
194 210 if _hg_command_specific; then
211 _hg_fix_wordlist
195 212 return
196 213 fi
197 214
@@ -205,6 +222,7 b' shopt -s extglob'
205 222 cmd=${cmd%%[$' \n']*}
206 223 canonical=1
207 224 _hg_command_specific
225 _hg_fix_wordlist
208 226 }
209 227
210 228 _hg_command_specific()
@@ -291,8 +309,8 b' shopt -s extglob'
291 309 return 0
292 310 }
293 311
294 complete -o bashdefault -o default -F _hg hg \
295 || complete -o default -F _hg hg
312 complete -o bashdefault -o default -o nospace -F _hg hg \
313 || complete -o default -o nospace -F _hg hg
296 314
297 315
298 316 # Completion for commands provided by extensions
General Comments 0
You need to be logged in to leave comments. Login now