refactor: use defer
This commit is contained in:
parent
a10e8264b9
commit
3f4ceeb01a
11
render.go
11
render.go
@ -174,7 +174,6 @@ func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
|
|||||||
if r.col == 0 {
|
if r.col == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.backward(r.previousCursor, r.previousCursor)
|
r.backward(r.previousCursor, r.previousCursor)
|
||||||
|
|
||||||
line := buffer.Text()
|
line := buffer.Text()
|
||||||
@ -190,11 +189,12 @@ func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer r.out.Flush()
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
r.out.HideCursor()
|
r.out.HideCursor()
|
||||||
defer func() {
|
defer r.out.ShowCursor()
|
||||||
r.out.ShowCursor()
|
|
||||||
}()
|
|
||||||
r.renderPrefix()
|
r.renderPrefix()
|
||||||
r.out.SetColor(r.inputTextColor, r.inputBGColor, false)
|
r.out.SetColor(r.inputTextColor, r.inputBGColor, false)
|
||||||
r.out.WriteStr(line)
|
r.out.WriteStr(line)
|
||||||
@ -216,9 +216,6 @@ func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
|
|||||||
cursor += len(suggest.Text)
|
cursor += len(suggest.Text)
|
||||||
r.lineWrap(cursor)
|
r.lineWrap(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.out.Flush()
|
|
||||||
|
|
||||||
r.previousCursor = cursor
|
r.previousCursor = cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user