Sublime Forum

Small bug in find panel

#1

In the find panel, when hitting ctrl+backspace to delete the last word, it will always leave 2 letters.

For example, if I have this in the find bar:
“this is a test example”

Then after hitting numerous ctrl+backspaces, I’ll still be left with:
“th”.
In the find panel, when hitting ctrl+backspace to delete the last word, it will always leave 2 letters.

For example, if I have this in the find bar:
“this is a test example”

Then after hitting numerous ctrl+backspaces, I’ll still be left with:
“th”.

0 Likes

#2

I’m not experiencing such behaviour. Are you using beta?

0 Likes

#3

I’m always using the current beta and this behavior is annoying me a long time. Maybe because of my non default keybinding ?

  <binding key="ctrl+backspace" command="leftEraseByCharClass"/>
0 Likes

#4

Try turning it off. I don’t have that custom key binding so it might well be the problem.

0 Likes

#5

Why should I turn this keybinding off?
I selected it with intent and not by random. I’m using sublime a little longer than two days.

0 Likes

#6

You turn it off to test that the binding isn’t the problem.

0 Likes

#7

leftEraseByCharClass isn’t a built-in command - you’ll have to check its source code

0 Likes

#8

UPDATE:

I checked it out, turns out it was leftEraseByCharClass. I forgot that PowerUser added that binding.
Turning it off makes the bug disappear.

I’ll have a look at the source code later, try and find the source of the bug.

Thanks!

0 Likes

#9

I changed “while pos > 1” to “while pos >=0” to get rid of the 2 letters
Original see http://www.sublimetext.com/forum/viewtopic.php?f=5&t=158&p=852&hilit=erase#p852

class LeftEraseByCharClassCommand (sublimeplugin.TextCommand):
  def run (self, view, args):
    # patterns
    space_pattern  = re.compile (r"\s")
    word_pattern   = re.compile (r"\w")
    symbol_pattern = re.compile (r"^\w\s]")

    for region in view.sel():
      pos = region.end()-1

      # check last char
      if word_pattern.match (view.substr (pos)):
        pattern = word_pattern
      elif space_pattern.match (view.substr (pos)):
        pattern = space_pattern
      else :
        pattern = symbol_pattern

      # removes according to last char
      while pos >= 0 and pattern.match (view.substr (pos)):
        view.erase (sublime.Region (pos, pos+1))
        pos -= 1
0 Likes