From fd5dd0970ebd0b08eaf8ea8dc55a015d29e56ab1 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 19 Jul 2024 10:51:21 -0700 Subject: [PATCH 1/2] 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. --- src/RPrompt.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/RPrompt.jl b/src/RPrompt.jl index 2930d773..09b67aa0 100644 --- a/src/RPrompt.jl +++ b/src/RPrompt.jl @@ -136,12 +136,20 @@ mutable struct RCompletionProvider <: LineEdit.CompletionProvider r::REPL.LineEditREPL end -function LineEdit.complete_line(c::RCompletionProvider, s) +if VERSION >= v"1.12.0-DEV.468" # Julia PR #54311 + 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 From 4cab8b6d01ed4b01dda096f7a9896bd4be3e0334 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 19 Jul 2024 11:06:08 -0700 Subject: [PATCH 2/2] Adjust `VERSION` check to accommodate 1.11 backport --- src/RPrompt.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/RPrompt.jl b/src/RPrompt.jl index 09b67aa0..2d75e1d6 100644 --- a/src/RPrompt.jl +++ b/src/RPrompt.jl @@ -136,7 +136,8 @@ mutable struct RCompletionProvider <: LineEdit.CompletionProvider r::REPL.LineEditREPL end -if VERSION >= v"1.12.0-DEV.468" # Julia PR #54311 +# 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)