Skip to content

Commit 4fb523b

Browse files
author
Stephan Dilly
committed
fix wrong file loaded in tree view
1 parent 82f5496 commit 4fb523b

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## Fixed
11+
- wrong file with same name shown in file tree ([#748](https://github.com/extrawurst/gitui/issues/748))
12+
1013
## [0.16.0] - 2021-05-28
1114

1215
**merge branch, merge commit**

src/components/revision_files.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,22 @@ impl RevisionFilesComponent {
148148

149149
fn selection_changed(&mut self) {
150150
//TODO: retrieve TreeFile from tree datastructure
151-
if let Some(file) = self.tree.selected_file().map(|file| {
152-
file.full_path()
153-
.strip_prefix("./")
154-
.unwrap_or_default()
155-
.to_string()
156-
}) {
157-
if let Some(item) = self
158-
.files
159-
.iter()
160-
.find(|f| f.path.ends_with(Path::new(&file)))
151+
if let Some(file) = self
152+
.tree
153+
.selected_file()
154+
.map(|file| file.full_path().to_string())
155+
{
156+
let path = Path::new(&file);
157+
if let Some(item) =
158+
self.files.iter().find(|f| f.path == path)
161159
{
162-
self.current_file.load_file(file, item);
160+
if let Ok(path) = path.strip_prefix("./") {
161+
return self.current_file.load_file(
162+
path.to_string_lossy().to_string(),
163+
item,
164+
);
165+
}
163166
}
164-
} else {
165167
self.current_file.clear();
166168
}
167169
}

0 commit comments

Comments
 (0)