From 40d6036c335e2d60080b8f2787a0597f152d6188 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Aguessy?=
 <fxaguessy@users.noreply.github.com>
Date: Fri, 8 Dec 2017 02:16:05 +0100
Subject: [PATCH] Fix panic 'integer divide by zero' when terminal width too
 low (#137)

---
 complete.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/complete.go b/complete.go
index 349fc3d..d1351f7 100644
--- a/complete.go
+++ b/complete.go
@@ -203,7 +203,9 @@ func (o *opCompleter) CompleteRefresh() {
 	// -1 to avoid reach the end of line
 	width := o.width - 1
 	colNum := width / colWidth
-	colWidth += (width - (colWidth * colNum)) / colNum
+	if colNum != 0 {
+		colWidth += (width - (colWidth * colNum)) / colNum
+	}
 
 	o.candidateColNum = colNum
 	buf := bufio.NewWriter(o.w)