summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Goodman <wagoodman@gmail.com>2019-04-06 13:28:54 -0400
committerAlex Goodman <wagoodman@gmail.com>2019-04-06 13:28:54 -0400
commit09296c0214c4cc7477fe53bc79c54805899c6d19 (patch)
treef197bd331c49fe7b3162d4bd6a9b6486e4f0a1ab
parentfa48fc1f810b7de1fbf1b93c9d6af42960125a3a (diff)
consider collapsed dirs in visible tree size (fixes #185)v0.7.2
-rw-r--r--README.md12
-rw-r--r--filetree/tree.go12
-rw-r--r--ui/filetree_controller.go3
3 files changed, 20 insertions, 7 deletions
diff --git a/README.md b/README.md
index ea01dfa..5121130 100644
--- a/README.md
+++ b/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.
diff --git a/filetree/tree.go b/filetree/tree.go
index b9cc834..46309ce 100644
--- a/filetree/tree.go
+++ b/filetree/tree.go
@@ -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
}
diff --git a/ui/filetree_controller.go b/ui/filetree_controller.go
index 2ce8573..cc53cc7 100644
--- a/ui/filetree_controller.go
+++ b/ui/filetree_controller.go
@@ -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()
}