Skip to content

Commit c539ec4

Browse files
committed
REPL: JuliaSyntax completions overhaul
This commit replaces the heuristic parsing done by REPLCompletions.completions with a new approach that parses the entire input buffer once with JuliaSyntax. In addition to fixing bugs, the more precise parsing should allow for new features in the future. Some features now work in more situations "for free", like dictionary key completion (the expression evaluated to find the keys is now more precise) and method suggestions (arguments beyond the cursor can be used to narrow the list). The tests have been updated to reflect slightly differing behaviour for string and Cmd-string completion: the new code returns a character range encompassing the entire string when completing paths (not observable by the user), and the behaviour of '~'-expansion has be tweaked to be consistent across all places where paths can be completed. Some escaping issues have also been fixed. Fixes: #55420, #55518, #55520, #55842, #56389, #57611
1 parent b93d838 commit c539ec4

File tree

4 files changed

+573
-633
lines changed

4 files changed

+573
-633
lines changed

stdlib/REPL/src/REPL.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import .LineEdit:
8686
PromptState,
8787
mode_idx
8888

89+
include("SyntaxUtil.jl")
8990
include("REPLCompletions.jl")
9091
using .REPLCompletions
9192

@@ -782,7 +783,7 @@ end
782783

783784
beforecursor(buf::IOBuffer) = String(buf.data[1:buf.ptr-1])
784785

785-
# Convert inclusive-inclusive 1-based char indexing to inclusive-exclusuive byte Region.
786+
# Convert inclusive-inclusive 1-based char indexing to inclusive-exclusive byte Region.
786787
to_region(s, r) = first(r)-1 => (length(r) > 0 ? nextind(s, last(r))-1 : first(r)-1)
787788

788789
function complete_line(c::REPLCompletionProvider, s::PromptState, mod::Module; hint::Bool=false)

0 commit comments

Comments
 (0)