zyedidia / micro

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

Panic with `open folder\` on Windows #3351

Closed T-Diedrich closed 1 month ago

T-Diedrich commented 3 months ago

micro panics on Windows when trying to open a folder from a command, e.g. open folder\.

The resulting backtrace is

Micro encountered an error: runtime.boundsError runtime error: index out of range [0] with length 0
runtime/panic.go:114 (0xada2dc)
github.com/kballard/go-shellquote@v0.0.0-20180428030007-95032a82bc51/unquote.go:88 (0xf063af)
github.com/kballard/go-shellquote@v0.0.0-20180428030007-95032a82bc51/unquote.go:59 (0xf05b85)
github.com/zyedidia/micro/v2/internal/action/command.go:963 (0xf3be9d)
github.com/zyedidia/micro/v2/internal/action/actions.go:1330 (0xf2bfe9)
github.com/zyedidia/micro/v2/internal/info/infobuffer.go:152 (0xf08305)
github.com/zyedidia/micro/v2/internal/action/infopane.go:206 (0xf3ff7f)
github.com/zyedidia/micro/v2/internal/action/infopane.go:54 (0xf3f151)
github.com/zyedidia/micro/v2/internal/action/infopane.go:129 (0xf3f8ef)
github.com/zyedidia/micro/v2/internal/action/infopane.go:93 (0xf3f5ce)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:474 (0xf776f4)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:394 (0xf76fac)
runtime/internal/atomic/types.go:194 (0xadf112)
runtime/asm_amd64.s:1650 (0xb0ea21)

This happens whether the folder exists or not and is especially annoying because it is suggested by the autocompletion feature.

On Linux, for open folder/, an error Error: folder/ is a directory and cannot be opened is shown, or Error parsing args Unterminated backslash-escape for open folder\, both of which would be preferable.

Commit hash: 68d88b57 OS: Windows 11 (Pro) x86_64 Terminal: Windows Terminal 1.20.11381.0

niten94 commented 3 months ago

The bug is not fixed but I think it is the same with the bug reported in this issue: #2666

JoeKar commented 1 month ago

Closed as duplicate of #2666 and already addressed with https://github.com/zyedidia/go-shellquote/pull/1.