fix: fix runtime error when r.col == 0
This commit is contained in:
parent
e1c654e8e9
commit
2a35ceea89
16
render.go
16
render.go
@ -162,16 +162,19 @@ func (r *Render) renderCompletion(buf *Buffer, completions *CompletionManager) {
|
|||||||
|
|
||||||
// Render renders to the console.
|
// Render renders to the console.
|
||||||
func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
|
func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
|
||||||
|
// In situations where a psuedo tty is allocated (e.g. within a docker container),
|
||||||
|
// window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions.
|
||||||
|
if r.col == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Erasing
|
||||||
|
r.clear(r.previousCursor)
|
||||||
|
|
||||||
line := buffer.Text()
|
line := buffer.Text()
|
||||||
prefix := r.getCurrentPrefix()
|
prefix := r.getCurrentPrefix()
|
||||||
cursor := len(prefix) + len(line)
|
cursor := len(prefix) + len(line)
|
||||||
|
|
||||||
// In situations where a psuedo tty is allocated (e.g. within a docker container),
|
|
||||||
// window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions.
|
|
||||||
if r.col > 0 {
|
|
||||||
// Erasing
|
|
||||||
r.clear(r.previousCursor)
|
|
||||||
|
|
||||||
// prepare area
|
// prepare area
|
||||||
_, y := r.toPos(cursor)
|
_, y := r.toPos(cursor)
|
||||||
|
|
||||||
@ -180,7 +183,6 @@ func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
|
|||||||
r.renderWindowTooSmall()
|
r.renderWindowTooSmall()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
r.renderPrefix()
|
r.renderPrefix()
|
||||||
|
Loading…
Reference in New Issue
Block a user