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

Support relative negative line ranges #3068

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ajesipow
Copy link

@ajesipow ajesipow commented Aug 10, 2024

Adds support for relative negative line ranges, e.g. -10: or :-10, see #2944.

This is implemented by buffering as many lines as the largest negative offset as a "look ahead" to determine if a line should be printed.

For example:

  • for a range -10: 10 lines are buffered and only once EOF is reached will the (last) lines in the buffer be emitted
  • for a range :-10 10 lines are buffered and lines are emitted as the buffer moves through the file, once EOF is reached the last lines in the buffer are discarded


#[derive(Debug, Clone)]
#[derive(Debug, Copy, Clone)]
Copy link
Author

Choose a reason for hiding this comment

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

We may not actually want to add this, since LineRange is pub and a future impl could make it not Copy and therefore require a breaking change.

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

Successfully merging this pull request may close these issues.

1 participant