go-prompt icon indicating copy to clipboard operation
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

Open ssreenivasrb opened this issue 7 years ago • 6 comments

https://github.com/c-bata/go-prompt/blob/e99fbc797b795e0a7a94affc8d44f6a0350d85f0/render.go#L248

ssreenivasrb avatar Feb 14 '18 09:02 ssreenivasrb

Thanks for reporting. just a minute please.

c-bata avatar Feb 14 '18 10:02 c-bata

Fixed by @orisano. Thanks.

c-bata avatar Feb 14 '18 11:02 c-bata

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

ssreenivasrb avatar Mar 27 '18 07:03 ssreenivasrb

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
}

ssreenivasrb avatar Mar 27 '18 07:03 ssreenivasrb

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.

x168 avatar Jul 23 '19 08:07 x168

I'd like to reopen this issue @c-bata, it still exists. It is fixed by PR #172 .

sebastianst avatar May 02 '20 15:05 sebastianst