Skip to content

Commit

Permalink
Fix for issue #93, in which blank lines are indented when a selection…
Browse files Browse the repository at this point in the history
… of lines are indented. This prevents that and adds a regression test for it to test_editorcommands.py
  • Loading branch information
allanderek committed Dec 4, 2013
1 parent aee8f74 commit bba02cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kaa/commands/editorcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,10 @@ def indent(self, wnd):
else:
cols = 0

s = mode.build_indent_str(cols + mode.indent_width)
self.replace_string(wnd, f, t, s, False)
eol = doc.geteol(tol)
if eol != t+1:
s = mode.build_indent_str(cols + mode.indent_width)
self.replace_string(wnd, f, t, s, False)
tol = doc.geteol(tol)
finally:
if wnd.document.undo:
Expand Down
7 changes: 7 additions & 0 deletions test/test_editorcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def test_blockindent(self):
cmd.indent(wnd)
assert wnd.document.gettext(0, 7) == ' abc'

def test_blockindentblanklines(self):
wnd = self._getwnd("abc\n\ndef method")
wnd.screen.selection.set_range(1, 6)
cmd = editorcommand.EditCommands()
cmd.indent(wnd)
assert wnd.document.gettext(0, 16) == " abc\n\n def"

def test_undo_ins(self):
wnd = self._getwnd("")
cmd = editorcommand.EditCommands()
Expand Down

0 comments on commit bba02cc

Please sign in to comment.