Home Download Buy Blog Forum Support

num_selections in key bindings is broken

num_selections in key bindings is broken

Postby madevilgenius on Tue Oct 11, 2011 6:57 pm

num_selections used to be 0 when you had only a single cursor and no selection. Now it doesn't match against anything if you don't have a selection.

In other words, this will never trigger anything:

{ "key": "num_selections", "operator": "equal", "operand": 0 },

Worse, it seems that if you have multiple cursors (but no selections), then num_selections is still an unknown, unmatchable value. So it's impossible to check in the key bindings whether there are multiple cursors. Can we get a num_cursors key to check for?
madevilgenius
 
Posts: 19
Joined: Tue Oct 11, 2011 6:51 pm

Re: num_selections in key bindings is broken

Postby jps on Wed Oct 12, 2011 2:01 am

num_selections has an issue in 2126, however it is working as expected in the current dev_build, at http://www.sublimetext.com/dev

num_selections can be used for both empty and non-empty selections (aka carets).
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: num_selections in key bindings is broken

Postby nick. on Wed Feb 01, 2012 2:56 am

Can you confirm that num_selections is working correctly in 2173?

I'm trying to disable the unindent command from Vintage command mode while adding the "single_selection" functionality. Here are the relevant user keybinds:
Code: Select all
   { "keys": ["ctrl+["], "command": "single_selection",
      "context": [ { "key": "num_selections", "operator": "not_equal", "operand": 1 } ] },

   { "keys": ["ctrl+["], "command": "none",
      "context": [ { "key": "setting.command_mode", "operand": true },
                   { "key": "num_selections", "operator": "equal", "operand": 0 } ] },


Currently, with the first 'ctrl+[' press, the selection is cleared, then with the second press the line is unindented.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: num_selections in key bindings is broken

Postby sublimator on Wed Feb 01, 2012 3:46 am

A selection can be `empty` in the sense of lacking `contents` and still be a selection.

Not sure what you are trying to do but maybe you want a different context?
Code: Select all
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: num_selections in key bindings is broken

Postby nick. on Thu Mar 01, 2012 7:20 pm

I recently learned that my understanding of num_selections was incorrect.

Basically I'd like to clear a selection using the CTRL+[ keybinding rather than ESC. That is, instead of CTRL+A, ESC, I'd like to be able to do CTRL+A, CTRL+[. Am I missing it, or is there no command to clear_selection? I scanned through all the default keybindings for escape, and none of the assigned commands seem to do the trick.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 21 guests