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

Refactor IRB::Context#prompting #889

Merged
merged 1 commit into from
Feb 25, 2024
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
4 changes: 1 addition & 3 deletions lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,7 @@ def verbose?
# StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
# for more information.
def prompting?
verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
@io.kind_of?(RelineInputMethod) ||
(defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
verbose? || @io.prompting?
end

# The return value of the last statement evaluated.
Expand Down
16 changes: 16 additions & 0 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def support_history_saving?
false
end

def prompting?
false
end

# For debug message
def inspect
'Abstract InputMethod'
Expand Down Expand Up @@ -91,6 +95,10 @@ def readable_after_eof?
true
end

def prompting?
STDIN.tty?
end

# Returns the current line number for #io.
#
# #line counts the number of times #gets is called.
Expand Down Expand Up @@ -220,6 +228,10 @@ def eof?
@eof
end

def prompting?
true
end

# For debug message
def inspect
readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
Expand Down Expand Up @@ -467,6 +479,10 @@ def eof?
@eof
end

def prompting?
true
end

# For debug message
def inspect
config = Reline::Config.new
Expand Down
Loading