Skip to content

Commit

Permalink
context.colorize_code -> context.colorize_input
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Sep 18, 2024
1 parent 97c7c6e commit ee267e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def parse_command(code)
end
end

def colorize_code(input, complete:)
def colorize_input(input, complete:)
if IRB.conf[:USE_COLORIZE] && IRB::Color.colorable?
lvars = local_variables || []
if parse_command(input)
Expand Down
14 changes: 6 additions & 8 deletions lib/irb/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,18 @@ def DEBUGGER__.capture_frames(*args)
DEBUGGER__::ThreadClient.prepend(SkipPathHelperForIRB)
end

if !@output_modifier_defined && !DEBUGGER__::CONFIG[:no_hint] && irb.context.io.is_a?(RelineInputMethod)
Reline.output_modifier_proc = proc do |output, complete:|
unless output.strip.empty?
cmd = output.split(/\s/, 2).first
if !DEBUGGER__::CONFIG[:no_hint] && irb.context.io.is_a?(RelineInputMethod)
Reline.output_modifier_proc = proc do |input, complete:|
unless input.strip.empty?
cmd = input.split(/\s/, 2).first

if !complete && DEBUGGER__.commands.key?(cmd)
output = output.sub(/\n$/, " # debug command\n")
input = input.sub(/\n$/, " # debug command\n")
end
end

IRB.CurrentContext.colorize_code(output, complete: complete)
irb.context.colorize_input(input, complete: complete)
end

@output_modifier_defined = true
end

true
Expand Down
4 changes: 2 additions & 2 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ def initialize(completor)
@completion_params = [preposing, target, postposing, bind]
@completor.completion_candidates(preposing, target, postposing, bind: bind)
}
Reline.output_modifier_proc = proc do |output, complete:|
IRB.CurrentContext.colorize_code(output, complete: complete)
Reline.output_modifier_proc = proc do |input, complete:|
IRB.CurrentContext.colorize_input(input, complete: complete)
end
Reline.dig_perfect_match_proc = ->(matched) { display_document(matched) }
Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE]
Expand Down

0 comments on commit ee267e7

Please sign in to comment.