Skip to content

Refactor find command output to ripgrep-style format with colors#4

Merged
feds01 merged 4 commits intofeds01:mainfrom
estyxx:refactor-find-output-ripgrep-format
Nov 1, 2025
Merged

Refactor find command output to ripgrep-style format with colors#4
feds01 merged 4 commits intofeds01:mainfrom
estyxx:refactor-find-output-ripgrep-format

Conversation

@estyxx
Copy link
Copy Markdown
Contributor

@estyxx estyxx commented Oct 31, 2025

This PR refactors the find command output to match ripgrep's familiar format, making results more compact.

Changes

  • Output format: Changed from styled snippet annotations to ripgrep-style grouped-by-file format
  • Color coding: Added terminal colors matching ripgrep's color scheme:
    • File paths in magenta/pink
    • Line numbers in bright green
    • Matched text highlighted in red
  • Grouping: Results are now grouped by file, with all matches for a file shown together

Before

CleanShot 2025-10-31 at 15 14 02@2x

After

CleanShot 2025-11-01 at 14 39 58@2x

@feds01 feds01 self-assigned this Oct 31, 2025
@feds01 feds01 self-requested a review October 31, 2025 18:29
Copy link
Copy Markdown
Owner

@feds01 feds01 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution ❤️ I think this is a nice improvement over the existing display of results. Happy to accept this, I've left a couple of nits on the PR. Once addresses, I think this can go in!

Comment thread crates/teamsearch/src/lib.rs Outdated
/// Get the line number (1-indexed) and byte range for a given byte position.
///
/// Returns a tuple of (line_number, line_start_byte, line_end_byte) where line_number is 1-indexed.
fn get_line_range(contents: &str, byte_pos: usize) -> (usize, usize, usize) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think we can move this into crates/teamsearch_utils/src/lines.rs

Comment thread crates/teamsearch/src/lib.rs Outdated
let mut message = Level::Info.title("match found");

// Now, construct the reports so that we can emit them to the user.
use colored::Colorize;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should be at the crate level.

Comment thread crates/teamsearch/src/lib.rs Outdated

/// Highlight matches in a line of text.
fn highlight_line_matches(line_content: &str, matches: &[Match]) -> String {
use colored::Colorize;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

♻️

}

/// Highlight matches in a line of text.
fn highlight_line_matches(line_content: &str, matches: &[Match]) -> String {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice! done it!

@estyxx estyxx force-pushed the refactor-find-output-ripgrep-format branch from a9eeb18 to f7cc233 Compare November 1, 2025 14:41
Copy link
Copy Markdown
Owner

@feds01 feds01 left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you ❤️

@feds01 feds01 merged commit 797605a into feds01:main Nov 1, 2025
1 check passed
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.

2 participants