Skip to content

Commit

Permalink
Merge pull request #12 from uncenter/feat/improve-preview-appearance
Browse files Browse the repository at this point in the history
Improve preview pane appearance
  • Loading branch information
yassinebridi authored Jun 28, 2024
2 parents 4debd27 + 26ce578 commit 38526e8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,14 @@ impl Component for Preview {
ReplaceTextKind::Simple => replace_text.to_string(),
};

spans
.push(Span::styled(matched_text, Style::default().fg(Color::LightRed).add_modifier(Modifier::CROSSED_OUT)));
spans.push(Span::styled(replaced_text, Style::default().fg(Color::White).bg(Color::Green)));
if replaced_text.is_empty() {
spans.push(Span::styled(matched_text, Style::default().bg(Color::Blue).add_modifier(Modifier::BOLD)));
} else {
spans
.push(Span::styled(matched_text, Style::default().bg(Color::LightRed).add_modifier(Modifier::CROSSED_OUT)));
spans.push(Span::styled(replaced_text, Style::default().fg(Color::White).bg(Color::Green)));
}

last_end = mat.end;
}

Expand All @@ -212,7 +217,6 @@ impl Component for Preview {
if let Some(last) = last_match {
if line_number > last + 1 {
let divider_line = Line::from("-".repeat(area.width as usize)).fg(Color::DarkGray);
lines.push(divider_line.clone());
lines.push(divider_line);
}
}
Expand All @@ -234,7 +238,7 @@ impl Component for Preview {
let text = Text::from(lines);

let preview_widget =
List::new(text).highlight_style(Style::default().bg(Color::Blue)).block(block).scroll_padding(4);
List::new(text).highlight_style(Style::default().add_modifier(Modifier::BOLD)).block(block).scroll_padding(4);

f.render_stateful_widget(preview_widget, layout.preview, &mut self.lines_state);

Expand Down

0 comments on commit 38526e8

Please sign in to comment.