Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make gobble usable in whitespace-indented languages

  • Loading branch information...
commit 5a43d86a4c8e0dd433e08378ce506a81922cb4fa 1 parent 3bb7c5e
@skyronic authored
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)):
Please sign in to comment.
Something went wrong with that request. Please try again.