Fix a division by zero on terminals that report 0 width.

This is true of emacs shell-mode.
This commit is contained in:
Ben Darnell 2016-02-18 17:25:32 -05:00
parent 8181d5ed14
commit c3db9c3189
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 { func (r *RuneBuffer) IdxLine() int {
totalWidth := runes.WidthAll(r.buf[:r.idx]) + r.PromptLen() totalWidth := runes.WidthAll(r.buf[:r.idx]) + r.PromptLen()
w := getWidth(r.cfg.StdoutFd) w := getWidth(r.cfg.StdoutFd)
if w < 0 { if w <= 0 {
return -1 return -1
} }
line := totalWidth / w line := totalWidth / w