Skip to content

Crash when attempting to bind two key sequences C-x C-c Quit and C-x C-s Save #3194

@khaytsus

Description

@khaytsus

Description of the problem or steps to reproduce

I've used an editor for many, many years called microEmacs and I'm binding a few common keys I am used to use there into Micro to make it a little easier to transition to it. I was able to bind Control-x Control-s to Save just fine,

bind <Ctrl-x><Ctrl-s> "Save"

And it works. But I was trying to bind Control-X Control-c to quit and Micro crashes as soon as I hit enter.

bind <Ctrl-x><Ctrl-c> "Quit"

Micro encountered an error: runtime.errorString runtime error: comparing uncomparable type action.KeySequenceEvent
/usr/lib/golang/src/runtime/alg.go:266 (0x55e57f146d1a)
ifaceeq: if eq == nil {
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/bindings.go:269 (0x55e57f603514)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/command.go:663 (0x55e57f60c8c6)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/command.go:983 (0x55e57f60f1e4)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/actions.go:1470 (0x55e57f5ff892)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/info/infobuffer.go:147 (0x55e57f5d258e)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/infopane.go:190 (0x55e57f61310c)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/infopane.go:54 (0x55e57f61255d)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/infopane.go:125 (0x55e57f612a59)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/internal/action/infopane.go:93 (0x55e57f6127d0)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/cmd/micro/micro.go:443 (0x55e57f642c1c)
/builddir/build/BUILD/micro-2.0.11/_build/src/github.com/zyedidia/micro/cmd/micro/micro.go:382 (0x55e57f64268a)
/usr/lib/golang/src/runtime/internal/atomic/types.go:194 (0x55e57f17bf72)
(*Uint32).Load: return Load(&u.value)
/usr/lib/golang/src/runtime/asm_amd64.s:1598 (0x55e57f1ac481)
goexit: DATA shifts<>+0x00(SB)/8, $0x0000000000000000

After experimenting some more, it appears that I can't bind this sort of thing twice, unrelated to the command or control characters. If I remove the bindings.json I can bind whatever, but if I set one, then set another one, it crashes every time. If I remove bindings.json I can create Ctrl-x Ctrl-c and set it to Quit, works, but now I can't create Ctrl-x Ctrl-s for Save.

bindings.json after I've created a "Quit" command:

{
"\u003cCtrl-x\u003e\u003cCtrl-c\u003e": "Quit",
"Alt-/": "lua:comment.comment",
"CtrlUnderscore": "lua:comment.comment"
}

If I manually make a binding.json of the following, these two bindings do function in the editor:

{
"\u003cCtrl-x\u003e\u003cCtrl-c\u003e": "Quit",
"\u003cCtrl-x\u003e\u003cCtrl-s\u003e": "Save",
}

And I can even add simple bindings later, like bind Ctrl-s "Find". 
It's just when I try to do another <Ctrl-x><Ctrl-s> type binding it fails.

Basic reproduction steps:

1. Run micro
2. Hit control-e, type bind <Ctrl-x><Ctrl-c> "Quit"
3. Hit control-e, type bind <Ctrl-x><Ctrl-s> "Save"

Specifications

Commit hash: 225927b
OS: Fedora 38
Terminal: xfce-terminal

I have also tried on the latest Release version from the github, 68d88b5

Sorry for the weird formatting, github markdown (?) was eating some of the sequences.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions