ruby-changes:64566
From: aycabta <ko1@a...>
Date: Thu, 24 Dec 2020 23:32:38 +0900 (JST)
Subject: [ruby-changes:64566] 0db9842b2c (master): [ruby/reline] Delete the last char of a line by dw
https://git.ruby-lang.org/ruby.git/commit/?id=0db9842b2c From 0db9842b2ca85709424d6c9c1e11caeae30dfae7 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Thu, 24 Dec 2020 21:24:35 +0900 Subject: [ruby/reline] Delete the last char of a line by dw This closes ruby/reline#229. https://github.com/ruby/reline/commit/3f0ae689c4 diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb index 09aff69..b7cecfe 100644 --- a/lib/reline/unicode.rb +++ b/lib/reline/unicode.rb @@ -459,7 +459,7 @@ class Reline::Unicode https://github.com/ruby/ruby/blob/trunk/lib/reline/unicode.rb#L459 end def self.vi_forward_word(line, byte_pointer) - if (line.bytesize - 1) > byte_pointer + if line.bytesize > byte_pointer size = get_next_mbchar_size(line, byte_pointer) mbchar = line.byteslice(byte_pointer, size) if mbchar =~ /\w/ @@ -474,7 +474,7 @@ class Reline::Unicode https://github.com/ruby/ruby/blob/trunk/lib/reline/unicode.rb#L474 else return [0, 0] end - while (line.bytesize - 1) > (byte_pointer + byte_size) + while line.bytesize > (byte_pointer + byte_size) size = get_next_mbchar_size(line, byte_pointer + byte_size) mbchar = line.byteslice(byte_pointer + byte_size, size) case started_by @@ -488,7 +488,7 @@ class Reline::Unicode https://github.com/ruby/ruby/blob/trunk/lib/reline/unicode.rb#L488 width += get_mbchar_width(mbchar) byte_size += size end - while (line.bytesize - 1) > (byte_pointer + byte_size) + while line.bytesize > (byte_pointer + byte_size) size = get_next_mbchar_size(line, byte_pointer + byte_size) mbchar = line.byteslice(byte_pointer + byte_size, size) break if mbchar =~ /\S/ diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb index edef573..45a5327 100644 --- a/test/reline/test_key_actor_vi.rb +++ b/test/reline/test_key_actor_vi.rb @@ -1215,6 +1215,29 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_vi.rb#L1215 assert_line('aaa ddd eee') end + def test_vi_delete_meta_with_vi_next_word_at_eol + input_keys("foo bar\C-[0w") + assert_byte_pointer_size('foo ') + assert_cursor(4) + assert_cursor_max(7) + assert_line('foo bar') + input_keys('w') + assert_byte_pointer_size('foo ba') + assert_cursor(6) + assert_cursor_max(7) + assert_line('foo bar') + input_keys('0dw') + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(3) + assert_line('bar') + input_keys('dw') + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(0) + assert_line('') + end + def test_vi_delete_meta_with_vi_next_char input_keys("aaa bbb ccc ___ ddd\C-[02w") assert_byte_pointer_size('aaa bbb ') -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/