mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Skip transpose-words if less than 2 word
This commit is contained in:
parent
fd17337228
commit
02880d1f4a
2 changed files with 77 additions and 0 deletions
|
@ -1418,6 +1418,7 @@ class Reline::LineEditor
|
|||
middle = @line.byteslice(middle_start, right_word_start - middle_start)
|
||||
right_word = @line.byteslice(right_word_start, after_start - right_word_start)
|
||||
after = @line.byteslice(after_start, @line.bytesize - after_start)
|
||||
return if left_word.empty? or right_word.empty?
|
||||
@line = before + right_word + middle + left_word + after
|
||||
from_head_to_left_word = before + right_word + middle + left_word
|
||||
@byte_pointer = from_head_to_left_word.bytesize
|
||||
|
|
|
@ -903,6 +903,82 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
assert_cursor_max(18)
|
||||
end
|
||||
|
||||
def test_ed_transpose_words_with_one_word
|
||||
input_keys('abc ')
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('abc ')
|
||||
assert_cursor(5)
|
||||
assert_cursor_max(5)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('abc ')
|
||||
assert_cursor(5)
|
||||
assert_cursor_max(5)
|
||||
input_keys("\C-b", false)
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('abc ')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(5)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('abc ')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(5)
|
||||
input_keys("\C-b" * 2, false)
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('ab')
|
||||
assert_cursor(2)
|
||||
assert_cursor_max(5)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('ab')
|
||||
assert_cursor(2)
|
||||
assert_cursor_max(5)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('abc ')
|
||||
assert_byte_pointer_size('ab')
|
||||
assert_cursor(2)
|
||||
assert_cursor_max(5)
|
||||
end
|
||||
|
||||
def test_ed_transpose_words_with_one_word_for_mbchar
|
||||
input_keys('あいう ')
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あいう ')
|
||||
assert_cursor(8)
|
||||
assert_cursor_max(8)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あいう ')
|
||||
assert_cursor(8)
|
||||
assert_cursor_max(8)
|
||||
input_keys("\C-b", false)
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あいう ')
|
||||
assert_cursor(7)
|
||||
assert_cursor_max(8)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あいう ')
|
||||
assert_cursor(7)
|
||||
assert_cursor_max(8)
|
||||
input_keys("\C-b" * 2, false)
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あい')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(8)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あい')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(8)
|
||||
input_keys("\M-t", false)
|
||||
assert_line('あいう ')
|
||||
assert_byte_pointer_size('あい')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(8)
|
||||
end
|
||||
|
||||
def test_ed_digit
|
||||
input_keys('0123')
|
||||
assert_byte_pointer_size('0123')
|
||||
|
|
Loading…
Add table
Reference in a new issue