consider collapsed dirs in visible tree size (fixes #185)
This commit is contained in:
parent
fa48fc1f81
commit
09296c0214
12
README.md
12
README.md
@ -74,14 +74,14 @@ Analyze and image and get a pass/fail result based on the image efficiency and w
|
||||
|
||||
**Ubuntu/Debian**
|
||||
```bash
|
||||
wget https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_linux_amd64.deb
|
||||
sudo apt install ./dive_0.7.1_linux_amd64.deb
|
||||
wget https://github.com/wagoodman/dive/releases/download/v0.7.2/dive_0.7.2_linux_amd64.deb
|
||||
sudo apt install ./dive_0.7.2_linux_amd64.deb
|
||||
```
|
||||
|
||||
**RHEL/Centos**
|
||||
```bash
|
||||
curl -OL https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_linux_amd64.rpm
|
||||
rpm -i dive_0.7.1_linux_amd64.rpm
|
||||
curl -OL https://github.com/wagoodman/dive/releases/download/v0.7.2/dive_0.7.2_linux_amd64.rpm
|
||||
rpm -i dive_0.7.2_linux_amd64.rpm
|
||||
```
|
||||
|
||||
**Arch Linux**
|
||||
@ -100,11 +100,11 @@ The above example assumes [`yay`](https://aur.archlinux.org/packages/yay/) as th
|
||||
brew tap wagoodman/dive
|
||||
brew install dive
|
||||
```
|
||||
or download the latest Darwin build from the [releases page](https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_darwin_amd64.tar.gz).
|
||||
or download the latest Darwin build from the [releases page](https://github.com/wagoodman/dive/releases/download/v0.7.2/dive_0.7.2_darwin_amd64.tar.gz).
|
||||
|
||||
**Windows**
|
||||
|
||||
Download the [latest release](https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_windows_amd64.zip).
|
||||
Download the [latest release](https://github.com/wagoodman/dive/releases/download/v0.7.2/dive_0.7.2_windows_amd64.zip).
|
||||
|
||||
**Go tools**
|
||||
Requires Go version 1.9 or higher.
|
||||
|
@ -127,13 +127,23 @@ func (tree *FileTree) VisibleSize() int {
|
||||
return nil
|
||||
}
|
||||
visitEvaluator := func(node *FileNode) bool {
|
||||
return !node.Data.ViewInfo.Collapsed && !node.Data.ViewInfo.Hidden
|
||||
if node.Data.FileInfo.IsDir {
|
||||
// we won't visit a collapsed dir, but we need to count it
|
||||
if node.Data.ViewInfo.Collapsed {
|
||||
size++
|
||||
}
|
||||
return !node.Data.ViewInfo.Collapsed && !node.Data.ViewInfo.Hidden
|
||||
}
|
||||
return !node.Data.ViewInfo.Hidden
|
||||
}
|
||||
err := tree.VisitDepthParentFirst(visitor, visitEvaluator)
|
||||
if err != nil {
|
||||
logrus.Errorf("unable to determine visible tree size: %+v", err)
|
||||
}
|
||||
|
||||
// don't include root
|
||||
size--
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -287,6 +287,9 @@ func (controller *FileTreeController) toggleCollapseAll() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if controller.vm.CollapseAll {
|
||||
controller.resetCursor()
|
||||
}
|
||||
controller.Update()
|
||||
return controller.Render()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user