Skip to content

Commit

Permalink
Add line break for search excerpts in raw mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfrishkorn committed Aug 30, 2023
1 parent 3de5a4b commit ccfa555
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// this gathers an excerpt from the supplied position
let excerpt =
s.analysis.get_excerpt(pos, context_words, context_raw)?;
excerpt.print();
excerpt.print(context_raw);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/snip/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Excerpt {

impl Excerpt {
/// Prints the formatted document excerpt
pub fn print(&self) {
pub fn print(&self, raw: bool) {
let position_range = format!(
"{}{}{}{}{}",
"[",
Expand All @@ -37,7 +37,9 @@ impl Excerpt {
);

print!(" {} ", position_range.bright_black());
print!("");
if raw {
println!();
}
for (i, term) in self.terms.iter().enumerate() {
// highlight if appropriate
match term.highlight {
Expand Down

0 comments on commit ccfa555

Please sign in to comment.