Fix regression: output printed on alternate screen

This commit is contained in:
Junegunn Choi 2017-07-19 13:17:06 +09:00
parent 6b5886c034
commit a9e64efe45
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1343,14 +1343,12 @@ func (t *Terminal) Loop() {
}() }()
} }
exit := func(code int, printQuery bool) { exit := func(getCode func() int) {
if !t.cleanExit && t.fullscreen && t.inlineInfo { if !t.cleanExit && t.fullscreen && t.inlineInfo {
t.placeCursor() t.placeCursor()
} }
t.tui.Close() t.tui.Close()
if printQuery { code := getCode()
t.printer(string(t.input))
}
if code <= exitNoMatch && t.history != nil { if code <= exitNoMatch && t.history != nil {
t.history.append(string(t.input)) t.history.append(string(t.input))
} }
@ -1398,11 +1396,12 @@ func (t *Terminal) Loop() {
case reqRedraw: case reqRedraw:
t.redraw() t.redraw()
case reqClose: case reqClose:
exit(func() int {
if t.output() { if t.output() {
exit(exitOk, false) return exitOk
} else {
exit(exitNoMatch, false)
} }
return exitNoMatch
})
case reqPreviewDisplay: case reqPreviewDisplay:
t.previewer.text = value.(string) t.previewer.text = value.(string)
t.previewer.lines = strings.Count(t.previewer.text, "\n") t.previewer.lines = strings.Count(t.previewer.text, "\n")
@ -1411,9 +1410,12 @@ func (t *Terminal) Loop() {
case reqPreviewRefresh: case reqPreviewRefresh:
t.printPreview() t.printPreview()
case reqPrintQuery: case reqPrintQuery:
exit(exitOk, true) exit(func() int {
t.printer(string(t.input))
return exitOk
})
case reqQuit: case reqQuit:
exit(exitInterrupt, false) exit(func() int { return exitInterrupt })
} }
} }
t.placeCursor() t.placeCursor()