Skip to content

Commit

Permalink
Windows cmd: Don't type anything when pressing ALT keys alone
Browse files Browse the repository at this point in the history
Fixes ruby#298
  • Loading branch information
larskanis committed Jul 8, 2021
1 parent 4e9dc3a commit 2135c9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/reline/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ def self.process_key_event(repeat_count, virtual_key_code, virtual_scan_code, ch
# It's treated as Meta+Space on Windows.
@@output_buf.push("\e".ord)
@@output_buf.push(char_code)
elsif control_key_state.anybits?(LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)
@@output_buf.push("\e".ord)
@@output_buf.concat(char.bytes)
elsif control_key_state.anybits?(ENHANCED_KEY)
case virtual_key_code # Emulate getwch() key sequences.
when VK_END
Expand Down
12 changes: 12 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,18 @@ def test_cyrillic_chars
EOC
end

def test_brackets
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write("\x80\M-[\x80\M-{\x80\M-}\x80\M-]\n")
close
assert_screen(<<~EOC)
Multiline REPL.
prompt> [{}]
=> [{}]
prompt>
EOC
end

def test_with_newline
omit if Reline::IOGate.win?
cmd = %Q{ruby -e 'print(%Q{abc def \\e\\r})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
Expand Down

0 comments on commit 2135c9f

Please sign in to comment.