Skip to content

Commit

Permalink
Fix REPL issue on Julia nightly (#541)
Browse files Browse the repository at this point in the history
* Fix REPL issue on Julia nightly

The `hint` keyword was added to the API of `complete_line`, and a
corresponding positional argument was added to `bslash_completions`.
This change adds the `hint` keyword to our method of `complete_line` and
passes it along to `bslash_completions`, which is defined locally to
accept and ignore the `hint` argument for earlier Julia versions.

* Adjust `VERSION` check to accommodate 1.11 backport
  • Loading branch information
ararslan authored Jul 19, 2024
1 parent 61b6ecb commit b6f4f19
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/RPrompt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,21 @@ mutable struct RCompletionProvider <: LineEdit.CompletionProvider
r::REPL.LineEditREPL
end

function LineEdit.complete_line(c::RCompletionProvider, s)
# 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"
using REPL.REPLCompletions: bslash_completions
else
function bslash_completions(string::String, pos::Int, hint::Bool=false)
return REPLCompletions.bslash_completions(string, pos)
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 = REPLCompletions.bslash_completions(full, lastindex(partial))[2]
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
end
Expand Down

0 comments on commit b6f4f19

Please sign in to comment.