go-prompt
go-prompt copied to clipboard
runtime error : integer divided by zero. Facing this issue when I am trying to run go-prompt as a docker container
https://github.com/c-bata/go-prompt/blob/e99fbc797b795e0a7a94affc8d44f6a0350d85f0/render.go#L248
Thanks for reporting. just a minute please.
Fixed by @orisano. Thanks.
The above issue still presists: The logs when the issue reoccured and i am using the go-prompt release version 0.2.1
panic: runtime error: integer divide by zero
goroutine 1 [running]: /github.com/c-bata/go-prompt.(*Render).toPos(...) /tmp/build-prompt-1.0.0-631788168/src//github.com/c-bata/go-prompt/render.go:248 /github.com/c-bata/go-prompt.(*Render).move(0xc42007d860, 0x5, 0x5, 0xc42001459e) /tmp/build-prompt-1.0.0-631788168/src//github.com/c-bata/go-prompt/render.go:232 +0x1a7 /github.com/c-bata/go-prompt.(*Render).backward(0xc42007d860, 0x5, 0x0, 0xc420039c00) /tmp/build-prompt-1.0.0-631788168/src//github.com/c-bata/go-prompt/render.go:228 +0x42 /github.com/c-bata/go-prompt.(*Render).Render(0xc42007d860, 0xc42004a380, 0xc42004a400) /tmp/build-prompt-1.0.0-631788168/src//github.com/c-bata/go-prompt/render.go:191 +0x16d /github.com/c-bata/go-prompt.(*Prompt).Run(0xc42004e3c0) /tmp/build-prompt-1.0.0-631788168/src//github.com/c-bata/go-prompt/prompt.go:52 +0xdf
Hey c-bata, Thank you for quick response on the issue: I am precently using the below workaround and it works pretty fine, pls review it.
diff ::>>
// x will not return 0 except for the first row. func (r *Render) toPos(cursor int) (x, y int) { col := int(r.col)
//code changes
if col == 0 {
return cursor,cursor
}
//ends here
if cursor > 0 && cursor%col == 0 {
return col - 1, cursor/col - 1
}
I am also facing the same problem with v0.2.3, should I use the above workaround? Since I saw the method toPos is modified after v0.2.1, but don't know why.
I'd like to reopen this issue @c-bata, it still exists. It is fixed by PR #172 .