Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/application/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod cursor;
mod delete;
mod insert;
mod monitor;
mod search;
mod normal;
mod search;
mod workspace;

pub fn handle_map() -> HashMap<&'static str, fn(&mut Application) -> Result<()>> {
Expand Down
2 changes: 1 addition & 1 deletion src/application/handler/search.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::application::mode::ModeData;
use crate::application::Application;
use crate::errors::*;
use crate::util::{position::Position, range::Range};
use crossterm::event::KeyCode;
use held_core::utils::{position::Position, range::Range};

pub fn exec_search(app: &mut Application) -> Result<()> {
if let ModeData::Search(ref mut search_data) = app.mode {
Expand Down
4 changes: 2 additions & 2 deletions src/application/mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use super::handler::handle_map;
use super::Application;

pub mod command;
pub mod motion;
pub mod delete;
pub mod error;
mod insert;
pub mod motion;
pub mod normal;
pub mod workspace;
pub mod search;
pub mod workspace;

pub enum ModeData {
Normal,
Expand Down
28 changes: 17 additions & 11 deletions src/application/mode/search.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use super::ModeRenderer;
use crate::util::range::Range;
use crate::{
errors::*,
view::{
colors::colors::Colors,
status_data::{buffer_status_data, StatusLineData},
style::CharStyle,
},
view::status_data::{buffer_status_data, StatusLineData},
};
use held_core::{
utils::range::Range,
view::{colors::Colors, style::CharStyle},
};
pub(super) struct SearchRenderer;

Expand All @@ -24,12 +23,19 @@ impl ModeRenderer for SearchRenderer {
if let super::ModeData::Search(ref search_data) = _mode {
let highlight_search_string = search_data.search_result.clone();

let highlight_search_string_slice: Option<&[Range]> =
let collected_ranges: Vec<(Range, CharStyle, Colors)> =
if !highlight_search_string.is_empty() {
Some(
&highlight_search_string[search_data.search_result_index
..search_data.search_result_index + 1],
)
highlight_search_string
.iter()
.map(|range| (range.clone(), CharStyle::Bold, Colors::Inverted))
.collect()
} else {
Vec::new()
};

let highlight_search_string_slice: Option<&[(Range, CharStyle, Colors)]> =
if !collected_ranges.is_empty() {
Some(collected_ranges.as_slice())
} else {
None
};
Expand Down