Skip to content

Commit

Permalink
prevent infinite render loop (fixes #184)
Browse files Browse the repository at this point in the history
  • Loading branch information
wagoodman committed Mar 27, 2019
1 parent e7bf771 commit fa48fc1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions ui/filetree_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 11 additions & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit fa48fc1

Please sign in to comment.