Skip to content

Commit

Permalink
Merge branch 'master' into pa/eachindex
Browse files Browse the repository at this point in the history
  • Loading branch information
palday authored Jul 19, 2024
2 parents f7aa5f3 + b6f4f19 commit d2d815c
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 d2d815c

Please sign in to comment.