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

--column emits incorrect column number #105

Closed
olson-dan opened this issue Sep 26, 2016 · 6 comments
Closed

--column emits incorrect column number #105

olson-dan opened this issue Sep 26, 2016 · 6 comments
Labels
bug A bug.

Comments

@olson-dan
Copy link

Trying to use ripgrep 0.2.0 with vim, I'm using "-n --color=never --column --no-header" as arguments, which lets me use a grepformat string of "%f:%l:%c:%m" to capture output and jump to the matches.

Problem is that the %c match in Vim expects a 0-based column to be output by the grep tool. The previous grep tool I was using matched this expectation. Lines are still expected to be 1-based. Documentation for vim's grepformat strings are here, for reference: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat

I've not encountered a way to do math on the column number within vim, although it may be possible. Wondering if you can support a syntax like "--column=0based", "--column=1based" or some other method to support 0-based columns.

@olson-dan
Copy link
Author

Just to add a note, checking with ag 0.18.1 (which I had laying around), it also appears to use 0-based columns.

@BurntSushi
Copy link
Owner

Really? @latortuga claimed 1-based columns in #18.

Looking at your vim docs link, I can't see where columns are specified to be 1-based?

When I use vim, I see its line numbers and column numbers reported as both 1-based.

@BurntSushi
Copy link
Owner

Ug, it looks like I have a mismatch:

[andrew@Serval tmp] echo 'zztest' > foo
[andrew@Serval tmp] rg --column test foo
1:4:zztest
[andrew@Serval tmp] rg --vimgrep test foo
1:3:zztest

Which one is correct?

@BurntSushi
Copy link
Owner

BurntSushi commented Sep 26, 2016

Well, obviously, 4 is wrong. The answer is either 3 (1-based) or 2 (0-based).

ag is 1-based:

[andrew@Serval tmp] ag --column test foo
1:3:zztest
[andrew@Serval tmp] ag --vimgrep test foo
foo:1:3:zztest

@olson-dan
Copy link
Author

--vimgrep is correct, I didn't see this option earlier. It solves my problem entirely.

@BurntSushi BurntSushi changed the title 0-based column support --column emits incorrect column number Sep 26, 2016
@BurntSushi
Copy link
Owner

@olson-dan That's good. Meanwhile, I will re-purpose this issue to fix the off-by-1 error with --column. (How embarrassing.) Thanks!

@BurntSushi BurntSushi added the bug A bug. label Sep 26, 2016
amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

2 participants