summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-08-23 17:12:37 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-08-23 17:12:37 +0900
commit43798fc2e801f4c5e6b9c3d048fb09eb8c7b6401 (patch)
treec02456bf986e836063ffadc8d26788494e065a89
parent9dc4b40d7a185b0448a15f2e2c6f7c46be738550 (diff)
Revert 1ab4289: Preview window of size 0 is allowed
-rw-r--r--src/options.go2
-rw-r--r--src/terminal.go5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/options.go b/src/options.go
index 38558771..a99ab0b6 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 b683c459..2208cf47 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())