Comments (7)
I confirm it leads to crash on current master c64add2 with
Micro encountered an error: runtime.errorString runtime error: comparing uncomparable type action.KeySequenceEvent
runtime/alg.go:266 (0x40519a)
github.com/zyedidia/micro/v2/internal/action/bindings.go:282 (0x8ac385)
github.com/zyedidia/micro/v2/internal/action/command.go:673 (0x8b67df)
github.com/zyedidia/micro/v2/internal/action/command.go:989 (0x8b9144)
github.com/zyedidia/micro/v2/internal/action/actions.go:1545 (0x8a8092)
github.com/zyedidia/micro/v2/internal/info/infobuffer.go:152 (0x87d494)
github.com/zyedidia/micro/v2/internal/action/infopane.go:206 (0x8bd68c)
github.com/zyedidia/micro/v2/internal/action/infopane.go:54 (0x8bc656)
github.com/zyedidia/micro/v2/internal/action/infopane.go:129 (0x8bcea2)
github.com/zyedidia/micro/v2/internal/action/infopane.go:93 (0x8bcb5e)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:476 (0x8f0287)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:395 (0x8efc9e)
runtime/proc.go:250 (0x43afd2)
runtime/asm_amd64.s:1594 (0x46a9a1)
Manually setting values int the bindings.json
file works
from micro.
Out of curiosity I tried to see if this was a regression and it seems like it maybe has always been this way, 2.0.7 was the first version that seemed to support this syntax and it crashes similarly.
from micro.
By adding small print in the code before error, I understood why it reports uncomparable types
function findEvent
internally use two functions: findSingleEvent
for single events and findEvents
for frequencies. First returns one event while another returns an array of such events wrapped to an object. So you can't compare. These two types are uncomparable but findEvent
just a facade that returns one of the result of those two functions.
micro/internal/action/bindings.go
Lines 111 to 136 in c64add2
micro/internal/action/bindings.go
Line 138 in c64add2
But I am curios why does type system doesn't report it as a problem? I findEvent
returns Event
as like findSingleEvent
but findEvents
returns KeySequenceEvent
how it can fit there?
micro/internal/action/bindings.go
Lines 237 to 252 in c64add2
from micro.
Interesting, before the comparison they should...at least from my understanding...type checked and in case of KeySequenceEvent
iterated once again and within that iteration compared against the entry, which is a KeyEvent
.
from micro.
You iterate through all the bindings in the bindings.json
And then compare them with event passed to TryBindKey
. If we will represent it like array of events in the bindings.json
we will get something like [Event,Event,KeySequenceEvent,Event,...]
. When you call the TryBindKey
you iterate trough this array and will check all the elemnts one by one if it is equal to the event you passed to TryBindKey
so it leads to bug
from micro.
Or maybe I am wrong. I am almost always wrong ¯\_(ツ)_/¯
. I've just deleted from my bindings all the events in order to prevent check between Event
and KeySequenceEvent
and the problem still persist 😅
from micro.
https://go.dev/ref/spec#Comparison_operators
Interface types that are not type parameters are comparable. Two interface values are equal if they have identical dynamic types and equal dynamic values or if both have value nil.
Struct types are comparable if all their field types are comparable.
A comparison of two interface values with identical dynamic types causes a run-time panic if that type is not comparable.
KeyEvent
is a comparable type, KeySequenceEvent
is not.
So comparing KeyEvent
with KeyEvent
is legal, comparing KeyEvent
with KeySequenceEvent
is also legal (and always returns false), but comparing KeySequenceEvent
with KeySequenceEvent
triggers a panic.
from micro.
Related Issues (20)
- disable error HOT 2
- Confusion over missing bindings
- Differing copy-paste mechanics between tmux and non-tmux HOT 3
- Calling clipboard.Write in lua crashes micro HOT 6
- 2.0.13 micro-2.0.13-linux-arm.tar.gz may have been tampered with HOT 12
- Micro panics when cd-ing to root
- How to toggle softwrap + wordwrap in editor, and how to make it a default setting? HOT 5
- Colors in Color Schems appear wrong. HOT 2
- DeleteLine does not delete selected lines HOT 8
- Micro reindents settings.json files with spaces on open HOT 1
- Nightly builds are not the current master branch 😭 HOT 3
- Binding Backspace related keys do not work on Windows HOT 1
- Autosave locally HOT 22
- Scrolling does not always go down with the cursor HOT 2
- Cannot click to move cursor to first character of document HOT 6
- Panic with `open folder\` on Windows HOT 1
- Empty line for no reason HOT 3
- [Feature request] Proposal of functionality improvement HOT 7
- [Bug] Overwriting of configuration file HOT 1
- Detect and display keyboard shortcuts? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micro.