dbcodeio / public

The Power of Databases, The Convenience of VS Code: All in One Place
29 stars 1 forks source link

Overwritten default keyboard shortcut #121

Open bendera opened 4 days ago

bendera commented 4 days ago

Hi,

The default shortcut (Ctrl+D Ctrl+B) for dbcode.connections.view.focus conflicts with the factory default shortcut for the "Add Selection to Next Find Match" feature.

mikeburgh commented 4 days ago

Indeed! Not sure how I missed that when picking this one.

Will have to go through and try and find something else... picking are slim when looking for a global keyboard map.

bendera commented 4 days ago

It seems to be a convention that the key chord commands begin with Ctrl+K. Both Ctrl+K Ctrl+D and Ctrl+K Ctrl+B are unassigned.

mikeburgh commented 4 days ago

I see ctrl/cmd+k ctrl/cmd+b is mapped to "Move Last Selection To Next Find Match" and ctrl/cmd+k ctrl/cmd+d mapped to "Set Selection Anchor"

So far I have found ctrl/cmd+h ctrl/cmd+m ctrl/cmd+y

are the only ones that are not mapped at all, but feels wrong to take one of those, and none really make sense.

ctrl/cmd+k b is unmapped, and sort of aligns to ctrl/cmd+b which is the sidebar toggle anyway, which this key map is similar to as it's pulling up the DB Explorer in the side bar..

bendera commented 3 days ago

An idea came to my mind. You could use the "when" clause:

{
    "key": "ctrl+d ctrl+b",
    "command": "dbcode.connections.view.focus",
    "when": "!editorHasSelection"
},

I just tried it. It works like a charm.

mikeburgh commented 3 days ago

Brilliant! Didn't think about using a negative to avoid the collision.. Tweaked it so it also works if you have a selection in the editor, but it's not focused.

{
    "command": "dbcode.connections.view.focus",
    "key": "ctrl+d ctrl+b",
    "mac": "cmd+d cmd+b",
    "when": "!editorHasSelection || (editorHasSelection && !editorTextFocus)"
}

Will go live in the next release!