Skip to content

Commit fa48fc1

Browse files
committed
prevent infinite render loop (fixes #184)
1 parent e7bf771 commit fa48fc1

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

Diff for: README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ Analyze and image and get a pass/fail result based on the image efficiency and w
7474

7575
**Ubuntu/Debian**
7676
```bash
77-
wget https://github.com/wagoodman/dive/releases/download/v0.7.0/dive_0.7.0_linux_amd64.deb
78-
sudo apt install ./dive_0.7.0_linux_amd64.deb
77+
wget https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_linux_amd64.deb
78+
sudo apt install ./dive_0.7.1_linux_amd64.deb
7979
```
8080

8181
**RHEL/Centos**
8282
```bash
83-
curl -OL https://github.com/wagoodman/dive/releases/download/v0.7.0/dive_0.7.0_linux_amd64.rpm
84-
rpm -i dive_0.7.0_linux_amd64.rpm
83+
curl -OL https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_linux_amd64.rpm
84+
rpm -i dive_0.7.1_linux_amd64.rpm
8585
```
8686

8787
**Arch Linux**
@@ -100,11 +100,11 @@ The above example assumes [`yay`](https://aur.archlinux.org/packages/yay/) as th
100100
brew tap wagoodman/dive
101101
brew install dive
102102
```
103-
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).
103+
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).
104104

105105
**Windows**
106106

107-
Download the [latest release](https://github.com/wagoodman/dive/releases/download/v0.7.0/dive_0.7.0_windows_amd64.zip).
107+
Download the [latest release](https://github.com/wagoodman/dive/releases/download/v0.7.1/dive_0.7.1_windows_amd64.zip).
108108

109109
**Go tools**
110110
Requires Go version 1.9 or higher.

Diff for: ui/filetree_controller.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,12 @@ func filterRegex() *regexp.Regexp {
331331
}
332332

333333
// onLayoutChange is called by the UI framework to inform the view-model of the new screen dimensions
334-
func (controller *FileTreeController) onLayoutChange() error {
334+
func (controller *FileTreeController) onLayoutChange(resized bool) error {
335335
controller.Update()
336-
return controller.Render()
336+
if resized {
337+
return controller.Render()
338+
}
339+
return nil
337340
}
338341

339342
// Update refreshes the state objects for future rendering.

Diff for: ui/ui.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ var GlobalKeybindings struct {
5959
filterView []keybinding.Key
6060
}
6161

62+
var lastX, lastY int
63+
6264
// View defines the a renderable terminal screen pane.
6365
type View interface {
6466
Setup(*gocui.View, *gocui.View) error
@@ -187,6 +189,14 @@ func layout(g *gocui.Gui) error {
187189
// TODO: this logic should be refactored into an abstraction that takes care of the math for us
188190

189191
maxX, maxY := g.Size()
192+
var resized bool
193+
if maxX != lastX {
194+
resized = true
195+
}
196+
if maxY != lastY {
197+
resized = true
198+
}
199+
lastX, lastY = maxX, maxY
190200
fileTreeSplitRatio := viper.GetFloat64("filetree.pane-width")
191201
if fileTreeSplitRatio >= 1 || fileTreeSplitRatio <= 0 {
192202
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 {
260270
if isNewView(viewErr, headerErr) {
261271
Controllers.Tree.Setup(view, header)
262272
}
263-
Controllers.Tree.onLayoutChange()
273+
Controllers.Tree.onLayoutChange(resized)
264274

265275
// Status Bar
266276
view, viewErr = g.SetView(Controllers.Status.Name, -1, maxY-statusBarHeight-statusBarIndex, maxX, maxY-(statusBarIndex-1))

0 commit comments

Comments
 (0)