Added wrap around feature to find menu

This commit is contained in:
RaspberryProgramming 2024-10-05 21:04:22 -04:00 committed by Jeremy Soller
parent a23a95b609
commit 5070f0c696
4 changed files with 33 additions and 3 deletions

View file

@ -337,6 +337,7 @@ pub enum Message {
FindReplaceValueChanged(String),
FindSearchValueChanged(String),
FindUseRegex(bool),
FindWrapAround(bool),
Focus,
GitProjectStatus(Vec<(String, PathBuf, Vec<GitStatus>)>),
GitStage(PathBuf, PathBuf),
@ -1708,7 +1709,7 @@ impl Application for App {
//TODO: do not compile find regex on every search?
match self.config.find_regex(&self.find_search_value) {
Ok(regex) => {
tab.search(&regex, true);
tab.search(&regex, true, self.config.find_wrap_around);
}
Err(err) => {
//TODO: put regex error in find box
@ -1731,7 +1732,7 @@ impl Application for App {
//TODO: do not compile find regex on every search?
match self.config.find_regex(&self.find_search_value) {
Ok(regex) => {
tab.search(&regex, false);
tab.search(&regex, false, self.config.find_wrap_around);
}
Err(err) => {
//TODO: put regex error in find box
@ -1812,6 +1813,10 @@ impl Application for App {
self.config.find_use_regex = find_use_regex;
return self.save_config();
}
Message::FindWrapAround(find_wrap_around) => {
self.config.find_wrap_around = find_wrap_around;
return self.save_config();
}
Message::GitProjectStatus(project_status) => {
self.git_project_status = Some(project_status);
}
@ -2855,6 +2860,12 @@ impl Application for App {
Message::FindUseRegex,
)
.into(),
widget::checkbox(
fl!("wrap-around"),
self.config.find_wrap_around,
Message::FindWrapAround,
)
.into(),
])
.align_items(Alignment::Center)
.padding(space_xxs)