summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Goodman <wagoodman@gmail.com>2019-03-26 23:03:15 -0400
committerAlex Goodman <wagoodman@gmail.com>2019-03-26 23:03:15 -0400
commitfa48fc1f810b7de1fbf1b93c9d6af42960125a3a (patch)
tree94e9c68484c517f69db01fbcb616e23186555c96
parente7bf771e7c79bc90375195891ff9636ad75cff49 (diff)
prevent infinite render loop (fixes #184)v0.7.1
-rw-r--r--README.md12
-rw-r--r--ui/filetree_controller.go7
-rw-r--r--ui/ui.go12
3 files changed, 22 insertions, 9 deletions
diff --git a/README.md b/README.md
index e1e3b27..ea01dfa 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.0/dive_0.7.0_linux_amd64.deb
-sudo apt install ./dive_0.7.0_linux_amd64.deb
+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
```
**RHEL/Centos**
```bash
-curl -OL https://github.com/wagoodman/dive/releases/download/v0.7.0/dive_0.7.0_linux_amd64.rpm
-rpm -i dive_0.7.0_linux_amd64.rpm
+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
```
**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.0/dive_0.7.0_darwin_amd64.tar.gz).
+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).
**Windows**
-Download the [latest release](https://github.com/wagoodman/dive/releases/download/v0.7.0/dive_0.7.0_windows_amd64.zip).
+Download the [latest release](https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_windows_amd64.zip).
**Go tools**
Requires Go version 1.9 or higher.
diff --git a/ui/filetree_controller.go b/ui/filetree_controller.go
index 29cd389..2ce8573 100644
--- a/ui/filetree_controller.go
+++ b/ui/filetree_controller.go
@@ -331,9 +331,12 @@ func filterRegex() *regexp.Regexp {
}
// onLayoutChange is called by the UI framework to inform the view-model of the new screen dimensions
-func (controller *FileTreeController) onLayoutChange() error {
+func (controller *FileTreeController) onLayoutChange(resized bool) error {
controller.Update()
- return controller.Render()
+ if resized {
+ return controller.Render()
+ }
+ return nil
}
// Update refreshes the state objects for future rendering.
diff --git a/ui/ui.go b/ui/ui.go
index d85065b..9daea71 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -59,6 +59,8 @@ var GlobalKeybindings struct {
filterView []keybinding.Key
}
+var lastX, lastY int
+
// View defines the a renderable terminal screen pane.
type View interface {
Setup(*gocui.View, *gocui.View) error
@@ -187,6 +189,14 @@ func layout(g *gocui.Gui) error {
// TODO: this logic should be refactored into an abstraction that takes care of the math for us
maxX, maxY := g.Size()
+ var resized bool
+ if maxX != lastX {
+ resized = true
+ }
+ if maxY != lastY {
+ resized = true
+ }
+ lastX, lastY = maxX, maxY
fileTreeSplitRatio := viper.GetFloat64("filetree.pane-width")
if fileTreeSplitRatio >= 1 || fileTreeSplitRatio <= 0 {
logrus.Errorf("invalid config value: 'filetree.pane-width' should be 0 < value < 1, given '%v'", fileTreeSplitRatio)
@@ -260,7 +270,7 @@ func layout(g *gocui.Gui) error {
if isNewView(viewErr, headerErr) {
Controllers.Tree.Setup(view, header)
}
- Controllers.Tree.onLayoutChange()
+ Controllers.Tree.onLayoutChange(resized)
// Status Bar
view, viewErr = g.SetView(Controllers.Status.Name, -1, maxY-statusBarHeight-statusBarIndex, maxX, maxY-(statusBarIndex-1))