zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.16k stars 1.17k forks source link

Crash on CtrlG #198

Closed sbrosinski closed 8 years ago

sbrosinski commented 8 years ago

When I press Ctrl+G to see the help, micro crashes:

Micro encountered an error: runtime error: index out of range runtime.errorString runtime error: index out of range /usr/local/go/src/runtime/panic.go:426 (0x815b9) gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz)) /usr/local/go/src/runtime/panic.go:15 (0x7fa89) panicindex: panic(indexError) /Users/Stephan/mygo/src/github.com/zyedidia/micro/cmd/micro/view.go:687 (0x45db6) (_View).DisplayView: highlightStyle = v.matches[viewLine][colN] /Users/Stephan/mygo/src/github.com/zyedidia/micro/cmd/micro/view.go:814 (0x46b18) (_View).Display: v.DisplayView() /Users/Stephan/mygo/src/github.com/zyedidia/micro/cmd/micro/micro.go:182 (0x2184b) RedrawAll: v.Display() /Users/Stephan/mygo/src/github.com/zyedidia/micro/cmd/micro/micro.go:289 (0x225ce) main: RedrawAll() /usr/local/go/src/runtime/proc.go:188 (0x830d0) main: main_main() /usr/local/go/src/runtime/asm_amd64.s:1998 (0xb1411) goexit: BYTE $0x90 // NOP

My go env:

GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/Stephan/mygo" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GO15VENDOREXPERIMENT="1" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common" CXX="clang++" CGO_ENABLED="1"

zyedidia commented 8 years ago

Could you give me the file that you were viewing when you pressed CtrlG, because it seems to be working fine for me.

Also what is the output of micro -version?

sbrosinski commented 8 years ago

I just couldn't reproduce it again, now I can.

To make it interesting, this error only occurs when I connect my external display. If I disconnect it, CtrlG works. When the error occurs, it even occurs on an empty buffer. No file loaded.

To me it looks like it depends on the size of the terminal window. I'm on OSX 10.11 (El Captain) using iTerm2 2.9. When I make my terminal window smaller, the error also does not happen.

I build the version myself from the master branch of this repo. Micro version: e890c87 I can download the binary release and see if it happens there too.

wrdls commented 8 years ago

I'm experiencing the same issue on Arch Linux. It always happens for me and doesn't seem to be related to terminal size or empty buffer. I only installed micro today so I don't have a lot experience with it (but loving it so far!).

Micro encountered an error: runtime error: index out of range runtime.errorString runtime error: index out of range /home/zbyedidia/go/src/runtime/panic.go:426 (0x480849) /home/zbyedidia/go/src/runtime/panic.go:15 (0x47ed19) /home/zbyedidia/micro/cmd/micro/view.go:687 (0x444d76) /home/zbyedidia/micro/cmd/micro/view.go:814 (0x445ad8) /home/zbyedidia/micro/cmd/micro/micro.go:182 (0x42080b) /home/zbyedidia/micro/cmd/micro/micro.go:289 (0x42158e) /home/zbyedidia/go/src/runtime/proc.go:188 (0x482360) /home/zbyedidia/go/src/runtime/asm_amd64.s:1998 (0x4b1631)

Linux 4.6.4-1-ARCH x86_64 GNU/Linux GNOME Terminal 3.20.2 Micro version: e890c87 (installed from Arch Linux AUR)

GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="1" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"

zyedidia commented 8 years ago

Hmm, alright it seems like the issue is caused by the viewport changing size when a split is made and the syntax highlighting not re-highlighting, causing an index out of bounds error when it goes to draw the view and looks up the color of a specific row column that the syntax highlighter doesn't think exists.

Anyway, I'm not exactly sure under what circumstances this issue happens, but I think I know how to fix it.

Also I think this is probably a more general issue regarding splits. It will probably also crash when you open a split with a file that is syntax highlighted (given the correct circumstances).

zyedidia commented 8 years ago

I think I may have fixed the issue, but I can't reproduce it so I'm not sure. Let me know if it's fixed.

wrdls commented 8 years ago

It's fixed for me.

zyedidia commented 8 years ago

Alright great. I'll close this issue then. Please reopen if there is still a problem.

sbrosinski commented 8 years ago

Ok, works for me now too. Thank you.