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

Add --no-context-separator option #1390

Closed
wants to merge 1 commit into from
Closed

Conversation

MoSal
Copy link
Contributor

@MoSal MoSal commented Sep 26, 2019

--context-separator="" still adds a new line separator, and changing
that would be a breaking change.

This new option has clear intent, and preserves backward compatibility.

@BurntSushi
Copy link
Owner

What is your use case for this?

If we can make --context-separator '' work, then I'd prefer that. Even if it's technically a breaking change, that's the kind of change I'm generally okay with. We can just introduce it in the ripgrep 12 release.

@MoSal
Copy link
Contributor Author

MoSal commented Sep 26, 2019

What is your use case for this?

Let's take filtering M3U playlist files as an example. One can easily get the URL/file corresponding to the filtered playlist item with -A1. So basically you can echo #EXTM3U which is the header, and do the filtering, and you get a valid sub-playlist as output.

If we can make --context-separator '' work, then I'd prefer that.

The issue with that solution is providing a way for users to get the old behavior back. Using \n as a separator would give two empty lines not one. If we special-case \n, then \n would print one new line and \n\n would print three!

If you still want to go that route, the patch is ready.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. OK, I think I buy this, but we should not add a short flag for this.

src/app.rs Outdated Show resolved Hide resolved
 --context-separator='' still adds a new line separator, and changing
 that would be a breaking change.

 This new option has clear intent, and preserves backward compatibility.

Signed-off-by: Mohammad AlSaleh <[email protected]>
@MoSal MoSal changed the title Add -X/--no-context-separator option Add --no-context-separator option Sep 26, 2019
@BurntSushi BurntSushi closed this Feb 15, 2020
@BurntSushi BurntSushi reopened this Feb 15, 2020
@BurntSushi BurntSushi added the rollup A PR that has been merged with many others in a rollup. label Feb 15, 2020
BurntSushi pushed a commit that referenced this pull request Feb 15, 2020
--context-separator='' still adds a new line separator, which could
still potentially be useful. So we add a new `--no-context-separator`
flag that completely disables context separators even when the -A/-B/-C
context flags are used.

Closes #1390
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR that has been merged with many others in a rollup.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants