From 43798fc2e801f4c5e6b9c3d048fb09eb8c7b6401 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 23 Aug 2020 17:12:37 +0900 Subject: [PATCH] Revert 1ab4289: Preview window of size 0 is allowed --- src/options.go | 2 +- src/terminal.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/options.go b/src/options.go index 3855877..a99ab0b 100644 --- a/src/options.go +++ b/src/options.go @@ -995,7 +995,7 @@ func parsePreviewWindow(opts *previewOpts, input string) { opts.wrap = false tokens := strings.Split(input, ":") - sizeRegex := regexp.MustCompile("^[1-9][0-9]*%?$") + sizeRegex := regexp.MustCompile("^[0-9]+%?$") offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$") for _, token := range tokens { switch token { diff --git a/src/terminal.go b/src/terminal.go index b683c45..2208cf4 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -1697,10 +1697,11 @@ func (t *Terminal) Loop() { // We don't display preview window if no match if items[0] != nil { command := t.replacePlaceholder(commandTemplate, false, string(t.Input()), items) - height := t.pwindow.Height() - offset := t.evaluateScrollOffset(items, height) + offset := 0 cmd := util.ExecCommand(command, true) if t.pwindow != nil { + height := t.pwindow.Height() + offset = t.evaluateScrollOffset(items, height) env := os.Environ() lines := fmt.Sprintf("LINES=%d", height) columns := fmt.Sprintf("COLUMNS=%d", t.pwindow.Width())