Merge pull request #29 from bdarnell/div-by-zero

Fix a division by zero on terminals that report 0 width.
This commit is contained in:
Chzyer 2016-02-19 08:08:26 +08:00
commit 5aaa89df05
1 changed files with 1 additions and 1 deletions

View File

@ -320,7 +320,7 @@ func (r *RuneBuffer) MoveTo(ch rune, prevChar, reverse bool) (success bool) {
func (r *RuneBuffer) IdxLine() int {
totalWidth := runes.WidthAll(r.buf[:r.idx]) + r.PromptLen()
w := getWidth(r.cfg.StdoutFd)
if w < 0 {
if w <= 0 {
return -1
}
line := totalWidth / w