Type to search or seek (#859)

* WIP: type to search/seek

* Implement type to seek
This commit is contained in:
Jeremy Soller 2025-03-06 20:44:05 -07:00 committed by GitHub
parent 7874f96ef1
commit f95762bd44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 111 additions and 27 deletions

View file

@ -1055,6 +1055,16 @@ impl std::fmt::Display for Location {
}
impl Location {
pub fn normalize(&self) -> Self {
if let Some(mut path) = self.path_opt().map(|x| x.to_path_buf()) {
// Add trailing slash if location is a path
path.push("");
self.with_path(path)
} else {
self.clone()
}
}
pub fn path_opt(&self) -> Option<&PathBuf> {
match self {
Self::Desktop(path, ..) => Some(path),
@ -1873,7 +1883,7 @@ impl Tab {
pub fn new(location: Location, config: TabConfig) -> Self {
let history = vec![location.clone()];
Self {
location,
location: location.normalize(),
context_menu: None,
location_context_menu_point: None,
location_context_menu_index: None,
@ -2198,7 +2208,7 @@ impl Tab {
}
pub fn change_location(&mut self, location: &Location, history_i_opt: Option<usize>) {
self.location = location.clone();
self.location = location.normalize();
self.context_menu = None;
self.edit_location = None;
self.items_opt = None;