Skip to content

Feat: Add --hierarchy flag for showing parent context lines#3413

Open
yash3605 wants to merge 4 commits into
BurntSushi:masterfrom
yash3605:add_hierarchy_mode
Open

Feat: Add --hierarchy flag for showing parent context lines#3413
yash3605 wants to merge 4 commits into
BurntSushi:masterfrom
yash3605:add_hierarchy_mode

Conversation

@yash3605
Copy link
Copy Markdown

Implemented Feature suggested in Issue: #3395.

I was able to do it using a simple Stack. what I did was that - when we're reading file, we check the indentation of each line. if the indentation of current line is less than the previous ones then we Pop them from the stack otherwise we push. and when I match is found the Stack is printed as it is.

what I couldn't do was implementing the Stack thing via StandardSink or Sink. because the code base is modular and tightly coupled and I was facing some ownership issues when borrowing StandardSink and others. So I had to create the stack separately and then pass it forward by some workarounds like creating a SinkWrapper for Sink and then Pass the Map I have made for the output.

Same with Printing the final result. I could have used WriteColor trait but I was facing same Ownership issues and I couldn't borrow another mutable reference so here I went with plain Println!() statement.

Before Hierarchy:
20260523-113637

After Hierarchy (in Debug mode):
20260523-113708

After Hierarchy (in build/release):
20260523-114234

@yash3605
Copy link
Copy Markdown
Author

This last ci/test error is due to Github Actions Infrastructure. I have fixed most issues in ci.

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