Skip to content

Commit

Permalink
Remove useless begin/end [ci skip] (#680)
Browse files Browse the repository at this point in the history
The `rescue` was removed at 420e7d227011.
  • Loading branch information
nobu authored Aug 13, 2023
1 parent 3847532 commit 8fa688e
Showing 1 changed file with 48 additions and 50 deletions.
98 changes: 48 additions & 50 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,66 +159,64 @@ def close
end
end

begin
class ReadlineInputMethod < StdioInputMethod
def self.initialize_readline
require "readline"
rescue LoadError
else
include ::Readline
end
class ReadlineInputMethod < StdioInputMethod
def self.initialize_readline
require "readline"
rescue LoadError
else
include ::Readline
end

include HistorySavingAbility
include HistorySavingAbility

# Creates a new input method object using Readline
def initialize
self.class.initialize_readline
if Readline.respond_to?(:encoding_system_needs)
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
end
# Creates a new input method object using Readline
def initialize
self.class.initialize_readline
if Readline.respond_to?(:encoding_system_needs)
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
end

super
super

@eof = false
@eof = false

if Readline.respond_to?("basic_word_break_characters=")
Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
end
Readline.completion_append_character = nil
Readline.completion_proc = IRB::InputCompletor::CompletionProc
if Readline.respond_to?("basic_word_break_characters=")
Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
end
Readline.completion_append_character = nil
Readline.completion_proc = IRB::InputCompletor::CompletionProc
end

# Reads the next line from this input method.
#
# See IO#gets for more information.
def gets
Readline.input = @stdin
Readline.output = @stdout
if l = readline(@prompt, false)
HISTORY.push(l) if !l.empty?
@line[@line_no += 1] = l + "\n"
else
@eof = true
l
end
# Reads the next line from this input method.
#
# See IO#gets for more information.
def gets
Readline.input = @stdin
Readline.output = @stdout
if l = readline(@prompt, false)
HISTORY.push(l) if !l.empty?
@line[@line_no += 1] = l + "\n"
else
@eof = true
l
end
end

# Whether the end of this input method has been reached, returns +true+
# if there is no more data to read.
#
# See IO#eof? for more information.
def eof?
@eof
end
# Whether the end of this input method has been reached, returns +true+
# if there is no more data to read.
#
# See IO#eof? for more information.
def eof?
@eof
end

# For debug message
def inspect
readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
str += " and #{inputrc_path}" if File.exist?(inputrc_path)
str
end
# For debug message
def inspect
readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
str += " and #{inputrc_path}" if File.exist?(inputrc_path)
str
end
end

Expand Down

0 comments on commit 8fa688e

Please sign in to comment.