prevent infinite render loop (fixes #184)
This commit is contained in:
parent
e7bf771e7c
commit
fa48fc1f81
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.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.
|
||||
|
@ -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.
|
||||
|
12
ui/ui.go
12
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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user