diff --git a/CHANGELOG.md b/CHANGELOG.md index cfd062a9..61b86cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## Fixed +- wrong file with same name shown in file tree ([#748](https://github.com/extrawurst/gitui/issues/748)) + ## [0.16.0] - 2021-05-28 **merge branch, merge commit** diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index 1b3fefb9..5864a064 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -148,20 +148,22 @@ impl RevisionFilesComponent { fn selection_changed(&mut self) { //TODO: retrieve TreeFile from tree datastructure - if let Some(file) = self.tree.selected_file().map(|file| { - file.full_path() - .strip_prefix("./") - .unwrap_or_default() - .to_string() - }) { - if let Some(item) = self - .files - .iter() - .find(|f| f.path.ends_with(Path::new(&file))) + if let Some(file) = self + .tree + .selected_file() + .map(|file| file.full_path().to_string()) + { + let path = Path::new(&file); + if let Some(item) = + self.files.iter().find(|f| f.path == path) { - self.current_file.load_file(file, item); + if let Ok(path) = path.strip_prefix("./") { + return self.current_file.load_file( + path.to_string_lossy().to_string(), + item, + ); + } } - } else { self.current_file.clear(); } }