Skip to content

Commit 869e4b7

Browse files
author
Stephan Dilly
authored
fix path handling on windows (#762)
* this reduces memory overhead where nothing is folded up * makes folding work with windows path seperators
1 parent 0e7ac4a commit 869e4b7

File tree

6 files changed

+167
-154
lines changed

6 files changed

+167
-154
lines changed

CHANGELOG.md

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

1414
## Fixed
1515
- wrong file with same name shown in file tree ([#748](https://github.com/extrawurst/gitui/issues/748))
16+
- filetree collapsing broken on windows ([#761](https://github.com/extrawurst/gitui/issues/761))
1617

1718
### Internal
1819
- use git_repository_message [[@kosayoda](https://github.com/kosayoda)] ([#751](https://github.com/extrawurst/gitui/issues/751))

filetreelist/src/error.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ pub enum Error {
66
#[error("InvalidPath: `{0}`")]
77
InvalidPath(PathBuf),
88

9-
#[error("InvalidFilePath: `{0}`")]
10-
InvalidFilePath(String),
11-
129
#[error("TryFromInt error:{0}")]
1310
IntConversion(#[from] TryFromIntError),
1411
}

filetreelist/src/filetree.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
error::Result, filetreeitems::FileTreeItems,
33
tree_iter::TreeIterator, TreeItemInfo,
44
};
5-
use std::{collections::BTreeSet, usize};
5+
use std::{collections::BTreeSet, path::Path, usize};
66

77
///
88
#[derive(Copy, Clone, Debug)]
@@ -35,7 +35,7 @@ pub struct FileTree {
3535
impl FileTree {
3636
///
3737
pub fn new(
38-
list: &[&str],
38+
list: &[&Path],
3939
collapsed: &BTreeSet<&String>,
4040
) -> Result<Self> {
4141
let mut new_self = Self {
@@ -318,12 +318,12 @@ impl FileTree {
318318
mod test {
319319
use crate::{FileTree, MoveSelection};
320320
use pretty_assertions::assert_eq;
321-
use std::collections::BTreeSet;
321+
use std::{collections::BTreeSet, path::Path};
322322

323323
#[test]
324324
fn test_selection() {
325325
let items = vec![
326-
"a/b", //
326+
Path::new("a/b"), //
327327
];
328328

329329
let mut tree =
@@ -341,8 +341,8 @@ mod test {
341341
#[test]
342342
fn test_selection_skips_collapsed() {
343343
let items = vec![
344-
"a/b/c", //
345-
"a/d", //
344+
Path::new("a/b/c"), //
345+
Path::new("a/d"), //
346346
];
347347

348348
//0 a/
@@ -364,8 +364,8 @@ mod test {
364364
#[test]
365365
fn test_selection_left_collapse() {
366366
let items = vec![
367-
"a/b/c", //
368-
"a/d", //
367+
Path::new("a/b/c"), //
368+
Path::new("a/d"), //
369369
];
370370

371371
//0 a/
@@ -390,8 +390,8 @@ mod test {
390390
#[test]
391391
fn test_selection_left_parent() {
392392
let items = vec![
393-
"a/b/c", //
394-
"a/d", //
393+
Path::new("a/b/c"), //
394+
Path::new("a/d"), //
395395
];
396396

397397
//0 a/
@@ -417,8 +417,8 @@ mod test {
417417
#[test]
418418
fn test_selection_right_expand() {
419419
let items = vec![
420-
"a/b/c", //
421-
"a/d", //
420+
Path::new("a/b/c"), //
421+
Path::new("a/d"), //
422422
];
423423

424424
//0 a/
@@ -449,8 +449,8 @@ mod test {
449449
#[test]
450450
fn test_selection_top() {
451451
let items = vec![
452-
"a/b/c", //
453-
"a/d", //
452+
Path::new("a/b/c"), //
453+
Path::new("a/d"), //
454454
];
455455

456456
//0 a/
@@ -470,9 +470,9 @@ mod test {
470470
#[test]
471471
fn test_visible_selection() {
472472
let items = vec![
473-
"a/b/c", //
474-
"a/b/c2", //
475-
"a/d", //
473+
Path::new("a/b/c"), //
474+
Path::new("a/b/c2"), //
475+
Path::new("a/d"), //
476476
];
477477

478478
//0 a/

0 commit comments

Comments
 (0)