File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -285,11 +285,14 @@ _project_open_scan() {
285285}
286286
287287_project_open_cache_file () {
288- # Key the cache by root so changing PROJECT_OPEN_ROOT never reads stale paths.
288+ # Key the cache by a hash of the root so a different PROJECT_OPEN_ROOT never
289+ # reads a stale cache. Hashing (not char substitution) avoids path collisions;
290+ # trailing slashes are stripped so "/x" and "/x/" share one cache.
289291 local root key
290292 root=" $( _project_open_root) "
291- key=" ${root// \/ / _} "
292- printf ' %s\n' " ${XDG_CACHE_HOME:- ${HOME} / .cache} /project_open/projects${key} "
293+ root=" ${root%/ } "
294+ key=" $( printf ' %s' " ${root} " | cksum | cut -d' ' -f1) "
295+ printf ' %s\n' " ${XDG_CACHE_HOME:- ${HOME} / .cache} /project_open/projects-${key} "
293296}
294297
295298_project_open_build_cache () {
@@ -302,7 +305,7 @@ _project_open_build_cache() {
302305 dir=" ${cache%/* } "
303306 mkdir -p " ${dir} " 2> /dev/null || return 1
304307 tmp=" $( mktemp " ${dir} /projects.XXXXXX" ) " || return 1
305- if _project_open_scan > " ${tmp} " && mv -f " ${tmp} " " ${cache} " ; then
308+ if _project_open_scan | LC_ALL=C sort > " ${tmp} " && mv -f " ${tmp} " " ${cache} " ; then
306309 return 0
307310 fi
308311 rm -f " ${tmp} "
Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ local -a candidates
1111if (( CURRENT == 2 )); then
1212 candidates=("${(@f)$(_project_open_projects)}")
1313 compadd -- "${candidates[@]}"
14- return
14+ return 0
1515fi
1616
1717if (( CURRENT == 3 )); then
1818 candidates=("${(@f)$(_project_open_targets "${words[CURRENT-1]}")}")
1919 compadd -- "${candidates[@]}"
20- return
20+ return 0
2121fi
2222
23- return
23+ return 0
You can’t perform that action at this time.
0 commit comments