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

Carriage return at end of results in Vim quickfix list #869

Closed
shyun3 opened this issue Mar 26, 2018 · 4 comments
Closed

Carriage return at end of results in Vim quickfix list #869

shyun3 opened this issue Mar 26, 2018 · 4 comments

Comments

@shyun3
Copy link

shyun3 commented Mar 26, 2018

What version of ripgrep are you using?

ripgrep 0.8.1
-SIMD -AVX

What operating system are you using ripgrep on?

macOS High Sierra Version 10.13.3

Describe your question, feature request, or bug.

I am using ripgrep as my grep tool in MacVim and I am noticing that after a search in files using the DOS line endings (fileformat is set to dos), all the results in the quickfix list have a carriage return character (^M) appended at the end. This is just a cosmetic thing, but would it be possible to get rid of these? I was previously using ack as my Vim grep tool and it did not include those characters at the end.

If this is a bug, what are the steps to reproduce the behavior?

  1. Test file for searching can be generated by running echo test > test.txt in a terminal.
  2. Open this file using Vim by running the following command: vim -u NONE -N test.txt. This ensures that no plugins get loaded.
  3. Set the file to use DOS line endings and save:
    :set ff=dos
    :w
    
  4. Run the following Ex commands to set the grep program:
    :set grepprg=rg\ --vimgrep
    :set grepformat=%f:%l:%c:%m
    
  5. Execute a grep command: :grep es. Press enter repeatedly until you are back in the Vim view of the file.
  6. Open the quickfix window: :copen. Notice that search result displays as test^M.

If this is a bug, what is the actual behavior?

Output of rg --vimgrep --debug es:

DEBUG/grep::search/grep/src/search.rs:195: regex ast:
Literal {
    chars: [
        'e',
        's'
    ],
    casei: false
}
DEBUG/grep::literals/grep/src/literals.rs:38: literal prefixes detected: Literals { lits: [Complete(es)], limit_size: 250, limit_class: 10 }
DEBUG/globset/globset/src/lib.rs:401: built glob set; 0 literals, 6 basenames, 0 extensions, 0 prefixes, 1 suffixes, 0 required extensions, 0 regexes
DEBUG/ignore::walk/ignore/src/walk.rs:1428: ignoring ./.DS_Store: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/Users/mhyun/.gitignore_global"), original: ".DS_Store", actual: "**/.DS_Store", is_whitelist: false, is_only_dir: false })))
test.txt:1:2:test

If this is a bug, what is the expected behavior?

It would be nice if the result in the quickfix window displays as test regardless of the format of the file being searched.

@BurntSushi
Copy link
Owner

This isn't an actionable bug report. Please fill out the issue template as requested. In particular, please include the command you're running, the actual output and the expected output.

My suspicion is that this is a duplicate of #416, but you haven't provided enough information, so I can't know for sure.

@shyun3
Copy link
Author

shyun3 commented Mar 26, 2018

Sorry for not following the template. I've updated my original comment that should hopefully be conforming.

@BurntSushi
Copy link
Owner

Oh I see. That is a much better bug report, thank you so much for filling in all the details. :-)

So yeah I don't think this is a bug in ripgrep. ripgrep probably should not be in the business of silently truncating characters from your search results. It would be pretty simple, I think, to run a script that post-processes the output to normalize line endings to whatever you desire, and I think that would be my preferred route.

@shyun3
Copy link
Author

shyun3 commented Mar 27, 2018

Ok, thank you.

@shyun3 shyun3 closed this as completed Mar 27, 2018
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

2 participants