Skip to content

Commit

Permalink
Skip em_exchange_mark without mark
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Nov 1, 2020
1 parent 710ca23 commit abb56e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/reline/line_editor.rb
Expand Up @@ -2342,6 +2342,7 @@ def finish
alias_method :set_mark, :em_set_mark

private def em_exchange_mark(key)
return unless @mark_pointer
new_pointer = [@byte_pointer, @line_index]
@previous_line_index = @line_index
@byte_pointer, @line_index = @mark_pointer
Expand Down
20 changes: 20 additions & 0 deletions test/reline/test_key_actor_emacs.rb
Expand Up @@ -1926,6 +1926,26 @@ def test_em_set_mark_and_em_exchange_mark
assert_equal([0, 0], @line_editor.instance_variable_get(:@mark_pointer))
end

def test_em_exchange_mark_without_mark
input_keys('aaa bbb ccc ddd')
assert_byte_pointer_size('aaa bbb ccc ddd')
assert_cursor(15)
assert_cursor_max(15)
assert_line('aaa bbb ccc ddd')
input_keys("\C-a\M-f", false)
assert_byte_pointer_size('aaa')
assert_cursor(3)
assert_cursor_max(15)
assert_line('aaa bbb ccc ddd')
assert_equal(nil, @line_editor.instance_variable_get(:@mark_pointer))
input_key_by_symbol(:em_exchange_mark)
assert_byte_pointer_size('aaa')
assert_cursor(3)
assert_cursor_max(15)
assert_line('aaa bbb ccc ddd')
assert_equal(nil, @line_editor.instance_variable_get(:@mark_pointer))
end

def test_modify_lines_with_wrong_rs
verbose, $VERBOSE = $VERBOSE, nil
original_global_slash = $/
Expand Down

0 comments on commit abb56e5

Please sign in to comment.