Fix :AckWindow for word-under-cursor searches#181
Fix :AckWindow for word-under-cursor searches#181AndrewRadev wants to merge 2 commits intomileszs:masterfrom
Conversation
If an argument was not given, the command didn't take the word under the cursor, since the locations that were given to the ack#Ack() function worked as an "args" argument. Separating "args" and "locations" fixes the issue.
:AckWindow for word-under-cursor searches|
This is great, thanks for the fix(es) and thinking through the proposal of an alternative for handling arguments. To me, it already helps the clarity of intent a great deal to pass around an array rather than string as in #171. Interestingly, by the way, this change to One request, and one question:
|
Yeah, you're right, I hadn't thought of that. I've renamed it.
Adding a vararg could work, especially if that vararg is that extra options dict. That way it would be possible to make further changes without much issue. Another thing I'm thinking of, though, is why not just create a private, script-local function that does the heavy lifting? That way the function! ack#Ack(cmd, args)
return s:Ack(a:cmd, a:args, [])
endfunctionIn any case, it's your call, so pick one option and I'll implement the change. I'm fine with either one, I think. |
As discussed in #171, this PR only fixes a bug with
:AckWindowand:AckHelp.Basically, if an argument was not given, the command doesn't take the word under the cursor, since the locations that are given to the
ack#Ack()function work as an "args" argument. Separating "args" and "locations" fixes the issue.Since locations are only used internally (if a user enters locations, they'll just be stuck in the catch-all
argsargument), it makes more sense for them to be a list.A different way of handling this would be to provide a dict with "options" or something, ruby-style. That way, any additional params that need to be communicated between functions privately would not need to change the signature.
Or, argument handling could somehow be extracted to a separate function, so every one of
ack#AckWindow,ack#Ackand so on invokes it first, something like:Or something. There would still be some extra work, since
ack#AckWindowcallsack#Ack, so both would have to do argument parsing, so I don't know if it's a good approach.Anyway, I'd rather just go for this solution, since I think it's simple enough and doesn't seem to have a lot of drawbacks. But let me know what you think.