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

Rename IDB::ReidlineInputMethod to IRB::RelineInputMethod #409

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ irb(main):001:0> irb_info
=>
Ruby version: 3.0.0
IRB version: irb 1.2.7 (2020-09-19)
InputMethod: ReidlineInputMethod with Reline 0.1.9 and /home/aycabta/.inputrc
InputMethod: RelineInputMethod with Reline 0.1.9 and /home/aycabta/.inputrc
.irbrc path: /home/aycabta/.irbrc
```

Expand Down
27 changes: 16 additions & 11 deletions lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Context
#
# The optional +input_method+ argument:
#
# +nil+:: uses stdin or Reidline or Readline
# +nil+:: uses stdin or Reline or Readline
# +String+:: uses a File
# +other+:: uses this as InputMethod
def initialize(irb, workspace = nil, input_method = nil)
Expand All @@ -48,8 +48,13 @@ def initialize(irb, workspace = nil, input_method = nil)
end
if IRB.conf.has_key?(:USE_MULTILINE)
@use_multiline = IRB.conf[:USE_MULTILINE]
elsif IRB.conf.has_key?(:USE_REIDLINE) # backward compatibility
@use_multiline = IRB.conf[:USE_REIDLINE]
elsif IRB.conf.has_key?(:USE_RELINE) # backward compatibility
@use_multiline = IRB.conf[:USE_RELINE]
elsif IRB.conf.has_key?(:USE_REIDLINE)
warn <<~MSG.strip
USE_REIDLINE is deprecated, please use USE_RELINE instead.
MSG
@use_multiline = IRB.conf[:USE_RELINE]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is for backward compatibility, shouldn't this be USE_REIDLINE?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maked sense.

else
@use_multiline = nil
end
Expand Down Expand Up @@ -83,14 +88,14 @@ def initialize(irb, workspace = nil, input_method = nil)
when nil
if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
# Both of multiline mode and singleline mode aren't specified.
@io = ReidlineInputMethod.new
@io = RelineInputMethod.new
else
@io = nil
end
when false
@io = nil
when true
@io = ReidlineInputMethod.new
@io = RelineInputMethod.new
end
unless @io
case use_singleline?
Expand Down Expand Up @@ -160,7 +165,7 @@ def main
# The current input method.
#
# Can be either StdioInputMethod, ReadlineInputMethod,
# ReidlineInputMethod, FileInputMethod or other specified when the
# RelineInputMethod, FileInputMethod or other specified when the
# context is created. See ::new for more # information on +input_method+.
attr_accessor :io

Expand Down Expand Up @@ -326,9 +331,9 @@ def main
# Alias for #use_singleline
alias use_singleline? use_singleline
# backward compatibility
alias use_reidline use_multiline
alias use_reline use_multiline
# backward compatibility
alias use_reidline? use_multiline
alias use_reline? use_multiline
# backward compatibility
alias use_readline use_singleline
# backward compatibility
Expand All @@ -346,7 +351,7 @@ def main
# Returns whether messages are displayed or not.
def verbose?
if @verbose.nil?
if @io.kind_of?(ReidlineInputMethod)
if @io.kind_of?(RelineInputMethod)
false
elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
false
Expand All @@ -361,11 +366,11 @@ def verbose?
end

# Whether #verbose? is +true+, and +input_method+ is either
# StdioInputMethod or ReidlineInputMethod or ReadlineInputMethod, see #io
# StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
# for more information.
def prompting?
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
@io.kind_of?(ReidlineInputMethod) ||
@io.kind_of?(RelineInputMethod) ||
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
end

Expand Down
11 changes: 10 additions & 1 deletion lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def inspect
end
end

class ReidlineInputMethod < InputMethod
class RelineInputMethod < InputMethod
include Reline

# Creates a new input method object using Reline
Expand Down Expand Up @@ -470,4 +470,13 @@ def inspect
str
end
end

class ReidlineInputMethod < RelineInputMethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that I missed this definition. I think it's a safe change and added #411 to pick up a few leftovers.

def initialize
warn <<~MSG.strip
IRB::ReidlineInputMethod is deprecated, please use IRB::RelineInputMethod instead.
MSG
super
end
end
end