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

Phantom line in result if file's last line contains LF #685

Open
dyng opened this issue Jun 4, 2015 · 0 comments
Open

Phantom line in result if file's last line contains LF #685

dyng opened this issue Jun 4, 2015 · 0 comments

Comments

@dyng
Copy link

dyng commented Jun 4, 2015

I have a file named foo, which contains two only-one-character lines: a and b.

~: cat foo
a
b

If I search this file with ag, I get a result which shows three lines in foo file, and there is a phantom blank line at the last of file.

~: ag -C 3 b
foo
1-a
2:b
3-  <-- This is the phantom line

After some attempts of guess and verification, I figured out that this issue may be related to LF at last line. The phantom line disappeared if I stripped the LF.

I'm not sure this behavior is a feature or a bug of ag, but vim treats LF at last line as an end of line but not a start of new line, therefore it appends LF by default. This causes troubles when searching these files with ag.

In contrast, ack does not append phantom line with same file.

~: ack -C 3 b
foo
1-a
2:b

Thanks in advance.

footnote:

os: OS X v10.10.3
ag: v0.30.0
ack: 2.14

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

No branches or pull requests

1 participant