Dine kommentarer

TextMate is also doing this. It's also convenient not having to use another key combo at this point.
Yeah - I've also seen command_mode but I still cannot catch all chars which would be passed thru. And this is actually what I need - intercept chars which would be passed thru and eventually deny them. Setting up a huge key binding is not really an option....
If I enter my original default value into the JSON settings file, I get a float from settings().get(). I wonder what happens if one presses such a big float into a too small c variable.
Anyway, 'hope Jon will fix this problem soon..
Yes - it seems that the whole file is being regenerated. Perhaps the internal int variable is too small to hold the value?
What about this?


    regions = []
    for sel in view.sel():
      #If we directly compare sel and view.word(sel), then in compares their
      #a and b values rather than their begin() and end() values. This means
      #that a leftward selection (with a > b) will never match the view.word()
      #of itself.
      #As a workaround, we compare the lengths instead.
      if len(sel) == len(view.word(sel)):
        sel = view.substr(sel).strip()
        if len(sel):
          regions += view.find_all(sel, sublime.LITERAL)
    view.add_regions("WordHighlight", regions, color_scope_name, draw_outlined)
Hmmm... view.word(sel) feels much better. Also you don't need the strip anymore, it seems.
As it works now it feels right to me. Thanks!

Update: Found a small bug :). When having a word selected and clicking into an empty line, the regions won't be removed. I've added 'view.erase_regions("WordHighlight")' before 'view.add_regions(…)' to fix this.
Update 2: Added ' and not sel.empty()' at the end of the if clause to prevent regex errors on empty selections.
So my solution for disabling a key binding when no context should match is another entry:

{ "keys": ["ctrl+alt+shift+t"], "command": "", "context":
[
{ "key": "selector", "operator": "not_equal", "operand": "source.python" },
{ "key": "selector", "operator": "not_equal", "operand": "source.perl" }
]
},

This effectively disables the binding when not in python or perl code.

Jon, should I open a bug entry for this?
Uhm... and strip doesn't work with LITERAL too?


Kundesupport af UserEcho