Skip to content

Commit 56c73a0

Browse files
hide any prints to stdio during complete_line
1 parent 91da4bf commit 56c73a0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

stdlib/REPL/src/LineEdit.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,14 @@ end
366366
# Prompt Completions & Hints
367367
function complete_line(s::MIState)
368368
set_action!(s, :complete_line)
369-
if complete_line(state(s), s.key_repeats, s.active_module)
369+
# suppress stderr/stdout prints during completion computation
370+
# i.e. ambiguous qualification warnings that are printed to stderr
371+
# TODO: remove this suppression once such warnings are better handled
372+
# TODO: but before that change Pipe to devnull once devnull redirects work for JL_STDERR etc.
373+
completions_exist = redirect_stdio(;stderr=Pipe(), stdout=Pipe()) do
374+
complete_line(state(s), s.key_repeats, s.active_module)
375+
end
376+
if completions_exist
370377
return refresh_line(s)
371378
else
372379
beep(s)
@@ -384,7 +391,13 @@ function check_for_hint(s::MIState)
384391
end
385392

386393
completions, partial, should_complete = try
387-
complete_line(st.p.complete, st, s.active_module; hint = true)::Tuple{Vector{String},String,Bool}
394+
# suppress stderr/stdout prints during completion computation
395+
# i.e. ambiguous qualification warnings that are printed to stderr
396+
# TODO: remove this suppression once such warnings are better handled
397+
# TODO: but before that change Pipe to devnull once devnull redirects work for JL_STDERR etc.
398+
completions, partial, should_complete = redirect_stdio(;stderr=Pipe(), stdout=Pipe()) do
399+
complete_line(st.p.complete, st, s.active_module; hint = true)::Tuple{Vector{String},String,Bool}
400+
end
388401
catch
389402
@debug "error completing line for hint" exception=current_exceptions()
390403
return clear_hint(st)

0 commit comments

Comments
 (0)