Skip to content

Commit

Permalink
[ruby/reline] Implement changing editing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ima1zumi authored and matzbot committed Apr 16, 2024
1 parent 54d472d commit 639449f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/reline/line_editor.rb
Expand Up @@ -2630,4 +2630,12 @@ def finish
@mark_pointer = new_pointer
end
alias_method :exchange_point_and_mark, :em_exchange_mark

private def emacs_editing_mode(key)
@config.editing_mode = :emacs
end

private def vi_editing_mode(key)
@config.editing_mode = :vi_insert
end
end
5 changes: 5 additions & 0 deletions test/reline/test_key_actor_emacs.rb
Expand Up @@ -1436,4 +1436,9 @@ def test_unix_line_discard
input_keys("\C-f\C-u", false)
assert_line_around_cursor('', '')
end

def test_vi_editing_mode
@line_editor.__send__(:vi_editing_mode, nil)
assert(@config.editing_mode_is?(:vi_insert))
end
end
5 changes: 5 additions & 0 deletions test/reline/test_key_actor_vi.rb
Expand Up @@ -911,4 +911,9 @@ def test_vi_motion_operators
input_keys("test = { foo: bar }\C-[BBBldt}b")
end
end

def test_emacs_editing_mode
@line_editor.__send__(:emacs_editing_mode, nil)
assert(@config.editing_mode_is?(:emacs))
end
end

0 comments on commit 639449f

Please sign in to comment.