fix wrong file loaded in tree view

This commit is contained in:
Stephan Dilly 2021-05-29 17:53:45 +02:00
parent 82f5496b04
commit 4fb523b9b1
2 changed files with 17 additions and 12 deletions

View File

@ -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**

View File

@ -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();
}
}