Skip to content

Commit

Permalink
Add test for range specification's boundary condition
Browse files Browse the repository at this point in the history
  • Loading branch information
lieryan authored and jonathanslenders committed Mar 6, 2020
1 parent 496a512 commit 862be13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions pyvim/commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,7 @@ def get_line_index_iterator(cursor_position_row, range_start, range_end):
range_start = range_end = cursor_position_row
else:
range_start = int(range_start) - 1
if not range_end:
range_end = range_start
range_end = int(range_end)
range_end = int(range_end) - 1 if range_end else range_start
return range(range_start, range_end + 1)

def get_transform_callback(search, replace, flags):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_substitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def test_substitute_range(editor, editor_buffer):
# == editor_buffer.buffer.text.index('Violet')


def test_substitute_range_boundaries(editor, editor_buffer):
given_sample_text(editor_buffer, 'Violet\n' * 4)

handle_command(editor, ':2,3s/Violet/Rose')

assert 'Violet\nRose\nRose\nViolet\n' in editor_buffer.buffer.text


def test_substitute_from_search_history(editor, editor_buffer):
given_sample_text(editor_buffer)
editor.application.current_search_state.text = 'blue'
Expand Down

0 comments on commit 862be13

Please sign in to comment.