summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-05-17 00:06:35 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-05-17 00:06:35 +0900
commit7a049644a825d802218fd287ad0d31bb178ba643 (patch)
treeb5ba32c222c1cc55be999725daa85e819243f6b0
parent17a13f00f8f17ba32b3f5737fda7055af023b269 (diff)
Fix panic when trying to render preview window of a negative height
Fix #3292
-rw-r--r--src/terminal.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 5748b3d6..8feb2799 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1235,6 +1235,8 @@ func (t *Terminal) resizeWindows(forcePreview bool) {
// Need a column to show scrollbar
pwidth -= 1
}
+ pwidth = util.Max(0, pwidth)
+ pheight = util.Max(0, pheight)
t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, true, noBorder)
}
verticalPad := 2
@@ -1973,7 +1975,7 @@ func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int)
}
func (t *Terminal) printPreview() {
- if !t.hasPreviewWindow() {
+ if !t.hasPreviewWindow() || t.pwindow.Height() == 0 {
return
}
numLines := len(t.previewer.lines)