Browse files

Make gobble usable in whitespace-indented languages

  • Loading branch information...
1 parent 3bb7c5e commit 5a43d86a4c8e0dd433e08378ce506a81922cb4fa @skyronic committed Mar 20, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 Gobble.py
View
13 Gobble.py
@@ -12,13 +12,20 @@ def run(self, edit):
if(len(sel) == 1):
passThrough = not (sel[0].empty())
+ cursorPoint = sel[0].begin();
+ lineRegion = self.view.line(cursorPoint)
+
+ # In whitespace-indented languages, if someone presses backspace on an empty line,
+ # it probably means "go to the previous level of indentation"
+ # So in that case, just pass-through!
+ if(cursorPoint == lineRegion.end()):
+ passThrough = True
+
if(passThrough):
self.view.run_command("left_delete")
return
- # Execute gobble
- cursorPoint = sel[0].a;
- lineStartPoint = self.view.line(cursorPoint).a
+ lineStartPoint = lineRegion.begin()
lineUptilPoint = self.view.substr(sublime.Region(lineStartPoint, cursorPoint))
if(not re.match('^\s+$', lineUptilPoint)):

0 comments on commit 5a43d86

Please sign in to comment.