ruby-changes:63927
From: aycabta <ko1@a...>
Date: Sat, 5 Dec 2020 03:09:20 +0900 (JST)
Subject: [ruby-changes:63927] 564aadce62 (master): [ruby/reline] Skip em_exchange_mark without mark
https://git.ruby-lang.org/ruby.git/commit/?id=564aadce62 From 564aadce626ff8dc94784d909d2a9c7bcd27b427 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Sun, 1 Nov 2020 22:59:03 +0900 Subject: [ruby/reline] Skip em_exchange_mark without mark https://github.com/ruby/reline/commit/abb56e5ec3 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 325475f..fde8ad9 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -2342,6 +2342,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2342 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 diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 7bb5ac3..a4b3b1c 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1926,6 +1926,26 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_emacs.rb#L1926 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 = $/ -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/