Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLCompletions: limit binding completions for explicitly specified modules #54858

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

aviatesk
Copy link
Sponsor Member

When completing a line where a module is explicitly accessed like A.xxx|, the current implementation of REPLCompletions considers all bindings available to A (e.g., including bindings exported by modules that A has usinged), but I think it would be more useful if the completion only includes the bindings defined by A. For example, the completion for the line LinearAlgebra.str| currently looks like

julia> LinearAlgebra.str
stride                      stride1
strides                     string
strip                       structured_broadcast_alloc

but in common cases, the desired completion would look like:

julia> LinearAlgebra.str
stride1 structured_broadcast_alloc

excluding bindings exported by Base and Core.

Following this observation, this commit makes REPL completions only show bindings defined by explicitly accessed module, unless shift is pressed. If shift is pressed, all bindings available in the module are shown as before.

…odules

When completing a line where a module is explicitly accessed like
`A.xxx|`, the current implementation of REPLCompletions considers all
bindings available to `A` (e.g., including bindings exported by modules
that `A` has `using`ed), but I think it would be more useful if the
completion only includes the bindings defined by `A`.
For example, the completion for the line `LinearAlgebra.str|` currently
looks like
```julia
julia> LinearAlgebra.str
stride                      stride1
strides                     string
strip                       structured_broadcast_alloc
```
but in common cases, the desired completion would look like:
```julia
julia> LinearAlgebra.str
stride1 structured_broadcast_alloc
```
excluding bindings exported by `Base` and `Core.`

Following this observation, this commit makes REPL completions only
show bindings defined by explicitly accessed module, unless
<kbd>shift</kbd> is pressed. If <kbd>shift</kbd> is pressed, all
bindings available in the module are shown as before.
@JeffBezanson JeffBezanson added the stdlib:REPL Julia's REPL (Read Eval Print Loop) label Jun 20, 2024
@aviatesk aviatesk merged commit 7ad4116 into master Jun 21, 2024
8 checks passed
@aviatesk aviatesk deleted the avi/complete-external-limited branch June 21, 2024 01:26
@ericphanson
Copy link
Contributor

does JSON.pa still complete to JSON.parse? since the function is defined in a submodule of JSON but is exported into the main module (and documented to be used as JSON.parse). For ExplicitImports.jl this kind of thing caused me to consider definitions in submodules to still be owned by the rootmodule (by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib:REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants