Repository navigation
Change quoted_insert and bracketed_paste to a single key input - #792
Conversation
| method_obj = method(method_symbol) | ||
| end | ||
| if @vi_arg | ||
| if key.match?(/\A\d\z/) |
There was a problem hiding this comment.
With the change in this pull request, inserting number with quoted_insert(\C-v9) and bracketed paste(\e[200~9\e[201~) has key="9" that wrongly match to /\A\d\z/.
We need to use method_symbol instead of this regexp.
| when :bracketed_paste_start | ||
| key = Reline::Key.new(io_gate.read_bracketed_paste, :insert_multiline_text) |
There was a problem hiding this comment.
📝 io_gate.read_bracketed_paste is defined only ansi.rb, so it cannot be invoked on Windows or other unsupported environments. But :bracketed_paste_start is also defined only ansi.rb, this code will never be reached on Windows or other environments.
There was a problem hiding this comment.
Thank you, I added a comment about it
| def test_bracketed_paste_insert | ||
| input_keys("d\C-aa") | ||
| input_key_by_symbol(:insert_multiline_text, char: "abc\n\C-abc") | ||
| assert_line_around_cursor("\C-abc", 'd') | ||
| end |
There was a problem hiding this comment.
Q: Why does this code serve as a test for bracketed_paste_insert?
There was a problem hiding this comment.
test_key_actor_emacs.rg is testing the behavior of LineEditor with key input mainly registered by key_actor/emacs.rb.
Bracketed paste (start_escape_sequence, content, end_escape_sequence) is converted into Key.new(content, :insert_multiline_text) in reline and passed to LineEditor.
As a test for LineEditor, we need to input this key to LineEditor.
Test of handling "\e[200~content\e[201~" is done in test_rendering.rb
I also added small tweak to the test:
input_keys("d\C-aa")
# ↓
set_line_around_cursor('a', 'd') # (and change it to 'A', 'Z')1d3b6bd to
0dc0109
Compare
Bracketed paste will be changed to
Reline::Key.new(pasted_content, :insert_multiline_text).This will simplify handling undo/redo of bracketed paste.
Quoted insert will be changed to
Reline::Key.new(char_to_be_inserted, :insert_raw_char).def ed_quoted_insert(renamed toinsert_raw_char) does not need to usewaiting_procanymore.