skuroda / FindKeyConflicts

Plugin for Sublime Text to help identify conflicting key mappings.
MIT License
149 stars 12 forks source link

Idea: add basic analysis for the context of conflicting keymaps #2

Open bizoo opened 11 years ago

bizoo commented 11 years ago

This is one of my overlap conflict:

 [ctrl+shift+r]
   delphi_switch_head_body                  Delphi                [{"operator": "equal", "operand": "source.pascal", "key": "selector"}]
   (ctrl+shift+r,ctrl+shift+c)
     python_regenerate_cache                User                  [{"operator": "equal", "operand": "source.python", "key": "selector"}]
   (ctrl+shift+r,ctrl+shift+d)
     goto_python_definition                 User                  [{"operator": "equal", "operand": "source.python", "key": "selector"}]

Actually, it's not a conflict because this keymap is used for different selector. Maybe you can analyze the context of the keymap to remove these keymaps from conflicts.

Another candidate could be this:

 [ctrl+v]
   paste                                    Default               
   fuzzy_clipboard                          FuzzyFileNav          [{"key": "fuzzy_paste"}]

or this:

 [home]
   move_to                                  Default               
   repl_home                                SublimeREPL           [{"operator": "equal", "operand": true, "key": "setting.repl"}]

Usually, I think that this kind of test are used to enabled a keymap only in a very limited scope, so it's not really a conflict, but there's no way to know it for sure. Maybe putting these conflicts in another section of the report is a good idea.

Thanks again for your work.

skuroda commented 11 years ago

Thanks for the feedback. I'd like to do some sort of work with the context, but as you pointed out, it's tricky. Though it is slightly less useful as is, I was thinking that having them all in one place would allow a quick overview for a given key combination.

Perhaps I can do some filtering if all of the commands have a context in which they execute. However, for those that don't, I don't I think it would be beneficial to move them to a separate report (or rather I don't have a good way to show it). The reason being, if an action exist both with and without a context, a user may get some unexpected behavior because they are unaware of the context. Let's use the ctrl+alt+n keybinding of AdvancedNewFile as an example. I would use one of yours but I haven't used the SublimeREPL plugin before and FuzzyFileNav was written well such that it won't produce the bad behavior I want (which is good).

So AdvancedNewFile uses the previously mentioned keybinding without a context to run the a command to create a new file. In ZenCoding, there is a similar key binding with a context. A user may be working within the context of ZenCoding, attempt to use the keybinding to create a new file, and find it does not work. By displaying these together by default, it would allow the user to quickly identify what else may be running (if they didn't enable logging of commands). I only know this happens because there was an issue about it for the AdvancedNewFile plugin :smile:

That being said, if you have some ideas for how to display context issues, in a way that makes sense, let me know.

Thanks again.