Redraw prompt only when necessary

This commit is contained in:
Junegunn Choi 2019-03-29 15:02:31 +09:00
parent 82efe6c60d
commit f39ab3875e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1635,7 +1635,8 @@ func (t *Terminal) Loop() {
t.mutex.Lock()
previousInput := t.input
events := []util.EventType{reqPrompt}
previousCx := t.cx
events := []util.EventType{}
req := func(evts ...util.EventType) {
for _, event := range evts {
events = append(events, event)
@ -1996,7 +1997,6 @@ func (t *Terminal) Loop() {
t.jumping = jumpDisabled
req(reqList)
}
t.mutex.Unlock() // Must be unlocked before touching reqBox
if changed {
if t.isPreviewEnabled() {
@ -2007,6 +2007,12 @@ func (t *Terminal) Loop() {
}
t.eventBox.Set(EvtSearchNew, t.sort)
}
if changed || t.cx != previousCx {
req(reqPrompt)
}
t.mutex.Unlock() // Must be unlocked before touching reqBox
for _, event := range events {
t.reqBox.Set(event, nil)
}