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

fix hightlighting issue when working with ack options #131

Closed
wants to merge 1 commit into from
Closed

fix hightlighting issue when working with ack options #131

wants to merge 1 commit into from

Conversation

mannih
Copy link

@mannih mannih commented May 26, 2014

I came across this bug today: set g:ackhighlight = 1 and do
:Ack -i something

This will result in every "w" being highlighted in your current window
and in the quick fix list. I "fixed" this by trying to strip out any
options before the actual search string.

The code is a bad hack and if you happen to also specifiy directories
for ack to search in, they will still be highlighted. But the code kind
of works and I didn't want to simply open an issue.

I came across this bug today: set g:ackhighlight = 1 and do
 :Ack -i something

This will result in every "w" being highlighted in your current window
and in the quick fix list. I "fixed" this by trying to strip out any
options before the actual search string.

The code is a bad hack and if you happen to also specifiy directories
for ack to search in, they will still be highlighted. But the code kind
of works and I didn't want to simply open an issue.
@kassio
Copy link
Contributor

kassio commented May 27, 2014

First of all, thank's for your contribution. But I guess this is a little complicated.

I guess we could solve this only changing the regex to ignore the words that are prefixed with -, something like that:

let @/ = matchstr(a:args, "\\v[^-]\<\\zs\\w+\>|['\"]\\zs[^\"]+\\ze['\"]")

WDYT?

@kassio kassio added the bug label May 27, 2014
@mannih
Copy link
Author

mannih commented May 27, 2014

Nice approach. Much better than mine. It does work for the case where I provide options to ack, but it fails for the option-less case.

I'll play with this for a bit. Thank you!

@kassio
Copy link
Contributor

kassio commented May 27, 2014

option-less case? I didn't get it?

@mannih
Copy link
Author

mannih commented May 27, 2014

Sorry.

This works:
:Ack -i test
"test" gets highlighted.

But this doesn't work:
:Ack test

@kassio
Copy link
Contributor

kassio commented May 27, 2014

My bad, try this one:

let @/ = matchstr(a:args, "\\v[^-]\\zs\\w+\>|['\"]\\zs[^\"]+\\ze['\"]")

@kassio kassio closed this in c3340b7 May 28, 2014
@mannih
Copy link
Author

mannih commented Jun 1, 2014

Much better now, but a little bit of the bug still remains:

:Ack test

will only highlight est and skip the t.

:Ack -i test

works just fine.

This matchstr seems to fix it completely:

let @/ = matchstr(a:args, "\\v\\zs[^- ]\\w+\>|['\"]\\zs[^\"]+\\ze['\"]")

I pulled the \\zs to the front and included a space in the character class that should not be matched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants