Open
Conversation
Collaborator
|
Hi Andrew, thanks for this, and apologies for the very long delay for review. This feature makes sense, despite the escaping gotcha there are a few of those that can come up with ack.vim anyway so I'd agree that it has enough practical utility as it is. I would like to review it separately from the bug fix though, if you don't mind—I think it's unfortunately clumsy, for instance, to have to pass the empty strings to work around the problem; there may not be a better easy alternative, but it'd be easier to consider and discuss in its own context. So, if you could pull that out into a separate commit and open another PR, we can leave this one open and rebase it afterward. Thanks! |
Author
|
Would be great to have. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enables the
:Ackfamily of commands to work on visual selections. If the user marks an area of text and types:Ack, the contents of the visual selection will be used as a search term. The other two cases, an:Ackthat uses the word under the cursor, and:Ack <term>which uses the given argument as a query, still work.The text is given as-is, which means if there are special characters in there, the results might be unexpected (say, marking
char* variablewould consider the*a special character). Still, this has often been a useful shortcut for me, even if it does break down for more complicated expressions (sometimes, just one<cword>is not enough).Note that this also fixes an issue I've (just) noticed with
:AckWindowand, I thnk,:AckHelp-- if you use them without arguments, taking the word under the cursor, they don't work. That's because the helper functions concatenate the empty argument list with a list of files, soa:argsis no longer empty and the code doesn't take the word under the cursor into account. If this PR is not accepted, I can make a separate pull request with just this fix. Incidentally, the reason I can't test:AckHelpproperly is that I seem to have so many plugins that the combined resulting command-line is too long to process correctly :). But I can't think of a good fix to that.I'd like to add a note to the documentation about the visual mode search, but I'm not sure where to do it. I think the documentation doesn't mention the "word under the cursor" functionality, so maybe we should add that somewhere as well?
I also have two additional features I'd like to propose, but it'll take me some time to prepare pull requests.