Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error : integer divided by zero. Facing this issue when I am trying to run go-prompt as a docker container #39

Open
ssreenivasrb opened this issue Feb 14, 2018 · 6 comments
Assignees

Comments

@ssreenivasrb
Copy link

if cursor > 0 && cursor%col == 0 {

@c-bata
Copy link
Owner

c-bata commented Feb 14, 2018

Thanks for reporting. just a minute please.

@c-bata
Copy link
Owner

c-bata commented Feb 14, 2018

Fixed by @orisano. Thanks.

@c-bata c-bata closed this as completed Feb 14, 2018
@ssreenivasrb
Copy link
Author

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

@c-bata c-bata reopened this Mar 27, 2018
@ssreenivasrb
Copy link
Author

ssreenivasrb commented Mar 27, 2018

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
}

@x168
Copy link

x168 commented Jul 23, 2019

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.

@sebastianst
Copy link

sebastianst commented May 2, 2020

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

Guttz added a commit to Guttz/go-prompt that referenced this issue Jun 26, 2024
* feat: show diagnostics on hover

* feat: show a whole line for diagnostics

* test: update test

* refactor: diagnostic message uses color from options

* refactor: comment on top of line

* refactor: remove unused param

* refactor: remove unnecessary check

* fix: make lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants