wofr06/lesspipe

zsh completion for archive doesn't work if less is an alias with some options.

iceblock-coder opened this issue · 2 comments

I set my less with following options.

less: aliased to less -MFXRi

Looks that causes completion fail to work.
With my poor knowledge to zsh completion, have no idea how to make it work.

Maybe you have a better idea, I'm just satisfied with my workaround.

index e95c05d..7a420e1 100644
--- a/_less
+++ b/_less
@@ -16,7 +16,11 @@ case $service in
   ;;
   *)
     if compset -P '*:' || compset -P '*='; then
-      fn="${words[2]%[:=]*}"
+      n=2
+      while [[ $words[$n] =~ ^-[-A-Za-z0-9=]+ ]]; do
+        n=$((n+1))
+      done
+      fn="${words[$n]%[:=]*}"
       res=$(lesscomplete "$fn")
       while read -r line; do
         [[ $line == /* ]] && slash=1```

Thanks for the fix. Given that this is a very rare situation I would (for the time being) not like to incorporate the change.