-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change quoted_insert and bracketed_paste to a single key input #792
Change quoted_insert and bracketed_paste to a single key input #792
Conversation
@@ -1004,7 +1005,7 @@ def wrap_method_call(method_symbol, method_obj, key, with_operator = false) | |||
method_obj = method(method_symbol) | |||
end | |||
if @vi_arg | |||
if key.match?(/\A\d\z/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
lib/reline.rb
Outdated
when :bracketed_paste_start | ||
key = Reline::Key.new(io_gate.read_bracketed_paste, :insert_multiline_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I added a comment about it
test/reline/test_key_actor_emacs.rb
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Why does this code serve as a test for bracketed_paste_insert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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_proc
anymore.