You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Overview
As we add REPL features, bugs related to the ad-hoc parsing done by
`REPLCompletions.completions` have crept in. This pull request replaces
most of the manual parsing (regex, `find_start_brace`) with a new
approach that parses the entire input buffer once, before and after the
cursor, using JuliaSyntax. We then query the parsed syntax tree to
determine the kind of completion to be done.
# Changes
- New, JuliaSyntax-based completions mechanism.
- The `complete_line` interface now has the option of replacing
arbitrary regions of text in the input buffer by returning a `Region`
(`Pair{Int, Int}` for consistency with the convention in LineEdit, and
`pos` being a 0-based byte offset).
- Fixes parsing-related bugs:
- fix#55420
- fix#55429
- fix#55518
- fix#55520
- fix#55842
- fix#56389
- fix#57307
- fix#57611
- fix#57624
- fix#58099
- Fixes some bugs that exist on 28d3bd5 that were found by fuzzing:
- `x \"` + `TAB` throws a `FieldError` exception
- String completion would sometimes delete the entire input buffer.
- Completions should not happen inside comments.
- The duplicate code for path completion in strings, `Cmd`-strings, and
the shell has been removed, causing paths to complete the same way for
all three. Now, `~` is expanded in two situations:
- If `foo` exists, or if `foo` does not exist but there are no
possible completions:
```
"~/foo/b|" =TAB=> "~/foo/bar|"
"~/foo/bar|" =TAB=> "/home/user/foo/bar|"
OR
"~/foo/bar"| =TAB=> "/home/user/foo/bar"|
```
- If the current path ends with a `/` and you hit TAB again:
```
"~/foo/|" =TAB=> "/home/user/foo/|"
OR
"~/foo/"| =TAB=> "/home/user/foo/"|
```
# Future work
- Method completions could be changed to look for methods with exactly
the given number of arguments if the closing `)` is present, and search
for signatures with the right prefix otherwise.
- It would be nice to be able to search by type as well as value
(perhaps by putting `::T` in place of arguments).
- Other REPL features could benefit from JuliaSyntax, so it might be
worth sharing the parse tree between completions and other features:
- Emacs-style sexpr navigation: `C-M-f`/`C-M-b`/`C-M-u`, etc.
- Improved auto-indent.
- It would be nice if hints worked even when the cursor is between text.
- `CursorNode` is a slightly tweaked copy of `SyntaxNode` from
JuliaSyntax that tracks the parent node but includes all trivia. It is
used with `seek_pos`, which navigates to the innermost node at a given
position so we can examine nearby nodes and the parent. This could
probably duplicate less code from JuliaSyntax.
(cherry picked from commit ff0a931)
0 commit comments