Skip to content
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

ed_quoted_insert doesn't work properly #321

Open
elfham opened this issue Aug 25, 2021 · 3 comments
Open

ed_quoted_insert doesn't work properly #321

elfham opened this issue Aug 25, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@elfham
Copy link
Contributor

elfham commented Aug 25, 2021

Description

ed_quoted_insert doesn't seem to work properly with some of keys.

("properly" means "different from same as readline 8.1")

Steps to Reproduce

Environment:

irb(main):001:0> irb_info
=>
Ruby version: 2.7.4
IRB version: irb 1.3.7 (2021-08-12)
InputMethod: ReidlineInputMethod with Reline 0.2.7
RUBY_PLATFORM: amd64-freebsd13
LANG env: ja_JP.UTF-8
  • no .irbrc, no .inputrc
  • PuTTYrv 0.76-ranvis2 (CJK)
  • Keyboard: US

Scenario:

Start irb --readline and type ", ", C-b.
The cursor is at the second ".

% irb --readline
irb(main):001:0" ""
                  _

Type C-v, C-a, Enter.

% irb --readline
irb(main):001:0> "^A"
=> "\u0001"
irb(main):002:0>

Do the same key operation on irb without --readline.

% irb
irb(main):001:0> "^A"
=> "\u0001"
irb(main):002:0>

Compare the input string "^A" and the output string "\u0001" with irb --readline.

Result:

HEX Chr key expected (readline) actual (Reline) OK/NG
00 NUL C-2 (see below) (see below) OK?
01 SOH C-a "^A" => "\u0001" "^A" => "\u0001" OK
02 STX C-b "^B" => "\u0002" "^B" => "\u0002" OK
03 ETX C-c "^C" => "\u0003" (see below) NG
04 EOT C-d "^D" => "\u0004" "^D" => "\u0004" OK
05 ENQ C-e "^E" => "\u0005" "^E" => "\u0005" OK
06 ACK C-f "^F" => "\u0006" "^F" => "\u0006" OK
07 BEL C-g "^G" => "\a" "^G" => "\a" OK
08 BS C-h "^H" => "\b" "^H" => "\b" OK
09 HT C-i (see below) (see below) NG
0A LF C-j (see below) (see below) OK?
0B VT C-k "^K" => "\v" "^K" => "\v" OK
0C FF C-l "^L" => "\f" "^L" => "\f" OK
0D CR C-m (see below) (see below) NG
0E SO C-n "^N" => "\u000E" "^N" => "\u000E" OK
0F SI C-o "^O" => "\u000F" "^O" => "\u000F" OK
10 DLE C-p "^P" => "\u0010" "^P" => "\u0010" OK
11 DC1 C-q "^Q" => "\u0011" "^Q" => "\u0011" OK
12 DC2 C-r "^R" => "\u0012" "^R" => "\u0012" OK
13 DC3 C-s "^S" => "\u0013" "^S" => "\u0013" OK
14 DC4 C-t "^T" => "\u0014" "^T" => "\u0014" OK
15 NAK C-u "^U" => "\u0015" "^U" => "\u0015" OK
16 SYN C-v "^V" => "\u0016" "^V" => "\u0016" OK
17 ETB C-w "^W" => "\u0017" "^W" => "\u0017" OK
18 CAN C-x "^X" => "\u0018" "^X" => "\u0018" OK
19 EM C-y "^Y" => "\u0019" "^Y" => "\u0019" OK
1A SUB C-z "^Z" => "\u001A" (see below) NG
1B ESC C-[, C-3 "^[" => "\e" "^[" => "\e" OK
1C FS C-\, C-4 "^\" => "\u001C" (see below) NG
1D GS C-], C-5 "^]" => "\u001D" "^]" => "\u001D" OK
1E RS C-6, S-C-6, S-C-' "^^" => "\u001E" "^^" => "" OK
1F US C-7, C-/, C--, S-C-- "^_" => "\u001F" "^_" => "\u001F" OK
7F DEL C-8 "^?" => "\u007F" "^?" => "\u007F" OK

C-2

Readline:

irb(main):001:0> ""
=> ""
irb(main):002:0>

Reline:

irb(main):001:0> "^@"
=> "\u0000"
irb(main):002:0>

Readline doesn't seem to be able to handle NUL, but Reline does.

C-c

Reline:

irb(main):001:0" ""
^C
irb(main):001:0>
irb(main):002:0>

C-c breaks the input.

C-i

Readline:

irb(main):001:0> "      "
=> "\t"
irb(main):002:0>

Reline:

irb(main):001:0> "
irb(main):002:0" "

Reline doesn't seem to be able to handle C-i.

C-j

Readline:

irb(main):001:0> "
"
=> "\n"
irb(main):003:0>

Reilne:

irb(main):001:0" "
irb(main):002:0> "
=> "\n"
irb(main):003:0>

The display is different, but it seems to work correctly.

C-m

Readline:

irb(main):001:0> "^M"
(irb):1: warning: encountered \r in middle of line, treated as a mere space
=> "\r"
irb(main):002:0>

Reline:

irb(main):001:0" "
irb(main):002:0> "
=> "\n"
irb(main):003:0>

C-z

Reline:

% irb
irb(main):001:0" ""
zsh: suspended  irb
% 
% 

irb goes to the background.

C-\, C-4

Reline:

irb(main):001:0> ""
zsh: quit (core dumped)  irb
% 

Bug of MRI ?

Terminal Emulator

PuTTYrv 0.76-ranvis2 (CJK)

@aycabta
Copy link
Member

aycabta commented Sep 6, 2021

Need to support:

Considering whether to support:

@aycabta
Copy link
Member

aycabta commented Sep 6, 2021

Thanks for the detailed research and report. I'm currently taking some steps to address the issue. Please wait a little longer.

@elfham
Copy link
Contributor Author

elfham commented Sep 14, 2021

Thanks for the fix.

I've tried #335, but there seem to be some problems.

First, I think TSTP should not be trapped except after ed_quoted_insert.
I think irb should usually go to the background with C-z.

Then, the behavior of C-z after ed_quoted_insert seems to be wrong.

% irb
irb(main):001:0" ""
                  _

Type C-v, C-z.

% irb
irb(main):001:0" ""

^Z is not displayed.
(^Z is buffered?)

Type Enter.

% irb
irb(main):001:0" "
irb(main):002:0" ^Z"

^Z is appeared with extra line break,
but the line does not committed yet.

There seems to be two problems.

  • the cursor position was not moved by ^Z
  • Enter should not input "\n" character, but enter the line here.

Then, type Enter again.

% irb
irb(main):001:0" "
irb(main):002:0" ^Z"
=> "\n\u001A"
irb(main):003:0>

brasic added a commit to brasic/reline that referenced this issue Apr 24, 2023
This PR was an effort to address ruby#321 (ed_quoted_insert doesn't work
properly) but per the reporter it did not work correctly.

Moreover, it introduced a major regression: Shell job control stopped
working in all applications that use reline, notably IRB.

Bash and other shells send SIGTSTP in response to C-z to implement job
suspension. Handling SIGSTP opts out of this functionality. For a
line oriented terminal program this should be avoided (not to mention,
this behavior diverges from readline's)
tompng pushed a commit that referenced this issue Apr 24, 2023
This PR was an effort to address #321 (ed_quoted_insert doesn't work
properly) but per the reporter it did not work correctly.

Moreover, it introduced a major regression: Shell job control stopped
working in all applications that use reline, notably IRB.

Bash and other shells send SIGTSTP in response to C-z to implement job
suspension. Handling SIGSTP opts out of this functionality. For a
line oriented terminal program this should be avoided (not to mention,
this behavior diverges from readline's)

Co-authored-by: Carl Brasic <cbrasic@drwholdings.com>
@ima1zumi ima1zumi added the enhancement New feature or request label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants