diff --git a/src/app.rs b/src/app.rs index ec8e475..9fa48cd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -8,7 +8,7 @@ use crate::{ ui::{self, Confirm, Help, Icon, Input, InputList, SelectCondition, Theme}, }; use anyhow::{anyhow, Result}; -use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers}; +use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers}; use ratatui::{ layout::{Alignment, Constraint, Layout, Rect}, widgets::{Block, Gauge, Padding, Paragraph}, diff --git a/src/models/search.rs b/src/models/search.rs index 26183ad..11747f1 100644 --- a/src/models/search.rs +++ b/src/models/search.rs @@ -123,7 +123,11 @@ impl Search { None } else { let before = if let Some(before) = config.before_context { - let start = if index < before { 0 } else { index - before }; + let start = if index < before { + 0 + } else { + index.saturating_sub(before) + }; slice[start..index] .iter() .enumerate() diff --git a/src/ui/confirm.rs b/src/ui/confirm.rs index 77f52ba..e4354dd 100644 --- a/src/ui/confirm.rs +++ b/src/ui/confirm.rs @@ -1,7 +1,7 @@ use super::Theme; use crate::ui; use anyhow::Result; -use crossterm::event::{Event, KeyCode, KeyEvent}; +use ratatui::crossterm::event::{Event, KeyCode, KeyEvent}; use ratatui::{ layout::{Constraint, Layout, Rect}, widgets::{Block, Clear, Padding, Paragraph}, diff --git a/src/ui/input.rs b/src/ui/input.rs index 003d4e8..5717281 100644 --- a/src/ui/input.rs +++ b/src/ui/input.rs @@ -1,6 +1,6 @@ use super::Theme; use crate::{models, ui}; -use crossterm::event::{Event, KeyCode, KeyEvent}; +use ratatui::crossterm::event::{Event, KeyCode, KeyEvent}; use ratatui::{ layout::Rect, widgets::{Block, Padding, Paragraph}, diff --git a/src/ui/input_list.rs b/src/ui/input_list.rs index 84de5fa..daa0b81 100644 --- a/src/ui/input_list.rs +++ b/src/ui/input_list.rs @@ -1,7 +1,7 @@ use super::{Icon, Input, MatchColors, Theme}; use crate::{models::SearchCondition, ui}; -use crossterm::event::{Event, KeyCode, KeyEvent}; use itertools::Itertools; +use ratatui::crossterm::event::{Event, KeyCode, KeyEvent}; use ratatui::{ layout::{Constraint, Layout, Rect}, style::{Modifier, Style}, diff --git a/src/ui/search_condition.rs b/src/ui/search_condition.rs index 61f86ef..13fb5c5 100644 --- a/src/ui/search_condition.rs +++ b/src/ui/search_condition.rs @@ -31,7 +31,7 @@ impl<'a> SearchCondition<'a> { } } -impl<'a> Display for SearchCondition<'a> { +impl Display for SearchCondition<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { let s = match &self.condition { models::SearchCondition::Exact(s) => format!("{} {}", self.icon.search(), s), diff --git a/src/ui/search_result.rs b/src/ui/search_result.rs index 2d64b25..af948ac 100644 --- a/src/ui/search_result.rs +++ b/src/ui/search_result.rs @@ -2,8 +2,8 @@ use super::{MatchColors, Theme}; use crate::models::file_result::LineResult; use crate::models::{self, MatchResult, SearchResultConfig}; use crate::ui; -use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers}; use nom::ToUsize; +use ratatui::crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers}; use ratatui::style::{Modifier, Style}; use ratatui::widgets::{Block, Padding, Paragraph}; use ratatui::{ diff --git a/src/ui/select_contidion.rs b/src/ui/select_contidion.rs index b57dae9..1721da3 100644 --- a/src/ui/select_contidion.rs +++ b/src/ui/select_contidion.rs @@ -1,5 +1,5 @@ use crate::{models::SearchCondition, ui}; -use crossterm::event::{Event, KeyCode, KeyEvent}; +use ratatui::crossterm::event::{Event, KeyCode, KeyEvent}; use ratatui::{ layout::{Constraint, Layout, Rect}, text::{Line, Span},