Don't include the bottom line of selection if blank

This commit is contained in:
Anthony Sottile
2020-02-21 19:35:21 -08:00
parent 75151505a7
commit 9683f15bcf
2 changed files with 17 additions and 0 deletions

View File

@@ -42,3 +42,18 @@ def test_sort_selection_does_not_include_eof(run, unsorted):
h.await_cursor_position(x=0, y=1)
h.press('^S')
assert unsorted.read() == 'a\nb\nc\nd\n'
def test_sort_does_not_include_blank_line_after(run, tmpdir):
f = tmpdir.join('f')
f.write('b\na\n\nd\nc\n')
with run(str(f)) as h, and_exit(h):
h.press('S-Down')
h.press('S-Down')
trigger_command_mode(h)
h.press_and_enter(':sort')
h.await_text('sorted!')
h.await_cursor_position(x=0, y=1)
h.press('^S')
assert f.read() == 'a\nb\n\nd\nc\n'