Skip to content
Draft
Changes from 1 commit
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
14 changes: 11 additions & 3 deletions src/RPrompt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
REvalError,
RParseEOF


function simple_showerror(io::IO, er)
Base.with_output_color(:red, io) do io
print(io, "ERROR: ")
Expand Down Expand Up @@ -137,22 +136,31 @@
end

# Julia PR #54311 (backported to 1.11) added the `hint` argument
if v"1.11.0-beta1.46" <= VERSION < v"1.12.0-DEV.0" || VERSION >= v"1.12.0-DEV.468"
@static if v"1.11.0-beta1.46" <= VERSION < v"1.12.0-DEV.0" || VERSION >= v"1.12.0-DEV.468"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is @static needed?

using REPL.REPLCompletions: bslash_completions
else
function bslash_completions(string::String, pos::Int, hint::Bool=false)
return REPLCompletions.bslash_completions(string, pos)
end
end

# Julia PR 54800 messed up REPL completion, fix adapted from https://github.com/JuliaLang/IJulia.jl/pull/1147
@static if VERSION < v"1.12.0-DEV.1716"
completion_text_ = REPLCompletions.completion_text
else
function completion_text_(c)::String
return REPLCompletions.named_completion(c).completion

Check warning on line 152 in src/RPrompt.jl

View check run for this annotation

Codecov / codecov/patch

src/RPrompt.jl#L151-L152

Added lines #L151 - L152 were not covered by tests
end
end

function LineEdit.complete_line(c::RCompletionProvider, s; hint::Bool=false)
buf = s.input_buffer
partial = String(buf.data[1:buf.ptr-1])
# complete latex
full = LineEdit.input_string(s)
ret, range, should_complete = bslash_completions(full, lastindex(partial), hint)[2]
if length(ret) > 0 && should_complete
return map(REPLCompletions.completion_text, ret), partial[range], should_complete
return map(completion_text_, ret), partial[range], should_complete
end

# complete r
Expand Down
Loading