Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZSH Tab completion not working on negative tags #35

Closed
kingo55 opened this issue Jul 23, 2020 · 9 comments
Closed

ZSH Tab completion not working on negative tags #35

kingo55 opened this issue Jul 23, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@kingo55
Copy link

kingo55 commented Jul 23, 2020

Really liking dstask - been using it for a couple of months now!

I've just found an issue where tab completion for tags works when using +ta -> +tagname but it doesn't work when you change the operand to - e.g. -ta does not resolve to -tagname.

Pretty minor issue though.

@ard0gg
Copy link
Contributor

ard0gg commented Jul 23, 2020

Do you have a context set? What happens if you ignore context -- before trying to enter a tag and perform completion?

@ard0gg
Copy link
Contributor

ard0gg commented Jul 23, 2020

Also what version are you running? I've tried v0.20 and built from latest source. I can only partially replicate. The only time I cannot complete tags is when I have a context set that does not include the tag. But it applies to both the + and - cases.

Edit: What I have experienced at least appears to be by design.

485             ts := dstask.LoadTasksFromDisk(dstask.NON_RESOLVED_STATUSES)                                                                     
486             // limit completions to available context, but not if the user is                                                                
487             // trying to change context, context ignore is on, or modify                                                                     
488             // command is being completed                                                                                                    
489             if !cmdLine.IgnoreContext &&                                                                                                     
490                 cmdLine.Cmd != dstask.CMD_CONTEXT &&                                                                                         
491                 cmdLine.Cmd != dstask.CMD_MODIFY {                                                                                           
492                 ts.Filter(context)                                                                                                           
493             }                                                        

@kingo55
Copy link
Author

kingo55 commented Jul 23, 2020

Thanks for checking out so quickly.

I'm still running 0.18 in MacOS/zsh/ohmyzsh and am not using contexts yet:

$ dstask context
Current context: %     

Tab completion works without - e.g. (#### are labels I've removed):

robertkingston@MacBook-Pro ~ $ dstask
+####           +mojito           +####              -mint             -personal         P1                add               edit              import-tw         next              open              show-next         show-projects     show-unorganised  sync
+####          +####      -####           -mojito           -####              P2                context           git               log               note              resolve           show-open         show-resolved     start             undo
+mint             +personal         -####          -####      P0                P3                done              help              modify            notes             show-active       show-paused       show-tags         stop              version

When I attempt tab completion after typing dstask -m, I get "bad option" errors:

robertkingston@MacBook-Pro ~ $ dstask -m
_dstask:compadd:1: bad option: -m
_dstask:compadd:1: bad option: -m
_dstask:compadd:1: bad option: -m

If I attempt tab completion after dstask -p, nothing shows up:

robertkingston@MacBook-Pro ~ $ dstask -p

And if I execute dstask -p or dstask -q then for some reason it shows some pending tasks of mine:

robertkingston@MacBook-Pro ~ $ dstask -p
Name      Value
ID        35
Priority  P3
Summary   Create contextual analytics tool
Status    pending
Project
Tags      mint
UUID      8a9335b3-a19a-4b94-a78f-cbdbbba02a91
Created   2020-07-20 15:11:59.091628 +1000 AEST

Notes on task 35:
Use Superset to expose page metrics in-page

Certainly not a deal breaking issue, but may be handy to fix if it's not just my shell.

@naggie
Copy link
Owner

naggie commented Jul 31, 2020

I can confirm that I get this too, using my fairly standard ZSH shell:
image

It's fine on bash though. Will investigate when I get time. Thanks for the report.

@naggie naggie added the bug Something isn't working label Jul 31, 2020
@naggie naggie changed the title Tab completion not working on negative tags ZSH Tab completion not working on negative tags Aug 1, 2020
@naggie naggie closed this as completed in 4eae4f4 Oct 20, 2020
@naggie
Copy link
Owner

naggie commented Oct 20, 2020

This is now fixed in master -- I've added the -- to compadd which makes zsh treat what dstask produces as plain words; dstask can only do basic completions with no elaboration.

From http://zsh.sourceforge.net/Doc/Release/Completion-Widgets.html

--

    This flag ends the list of flags and options. All arguments after it will be taken as the words to use as matches even if they begin with hyphens.

@naggie
Copy link
Owner

naggie commented Oct 21, 2020

Fixed in release v0.22 https://github.com/naggie/dstask/releases/tag/v0.22

@naggie
Copy link
Owner

naggie commented Oct 21, 2020

Do you have a context set? What happens if you ignore context -- before trying to enter a tag and perform completion?

Ha, I just realised @ard0gg had the solution all along. Oops :)

@kingo55
Copy link
Author

kingo55 commented Oct 21, 2020

If only I tested -- in the prompt and not just dstask -- before testing. 🤦

Either way, thanks for the fix guys!

@naggie
Copy link
Owner

naggie commented Oct 21, 2020

Oh, I now realies @ard0gg meant -- as a dstask parameter not a compadd parameter. Coincidence!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants