From b6f4f196b8b094bd40c4fd074c3391cb7b2d720a Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 19 Jul 2024 15:21:12 -0700 Subject: [PATCH] Fix REPL issue on Julia nightly (#541) * 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 --- src/RPrompt.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/RPrompt.jl b/src/RPrompt.jl index 2930d773..2d75e1d6 100644 --- a/src/RPrompt.jl +++ b/src/RPrompt.jl @@ -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