@@ -1120,6 +1120,21 @@ function complete_loading_candidates!(suggestions::Vector{Completion}, pkgstarts
1120
1120
return suggestions
1121
1121
end
1122
1122
1123
+ # Check whether we should still be limiting completions to the scope of the prefix
1124
+ # i.e. `Base.@time myvar` should complete to `Base.@time myvariable` because `myvariable`
1125
+ # is a valid expression in the active module, but not Base
1126
+ function in_scope_of_prefix (string:: String , pos:: Int , separatorpos:: Int )
1127
+ sep = string[separatorpos]
1128
+ sep == ' :' && return true # `using Base: foo` etc.
1129
+ sep == ' .' || return false
1130
+ pos <= separatorpos && return true
1131
+ after_separator = string[separatorpos+ 1 : pos]
1132
+ isempty (after_separator) && return true
1133
+ startswith (after_separator, " @" ) || return true
1134
+ # is a macro, so check for space or `(` that signifies the start of the macro call
1135
+ return ! any (in ((' ' , ' (' )), after_separator)
1136
+ end
1137
+
1123
1138
function complete_identifiers! (suggestions:: Vector{Completion} ,
1124
1139
context_module:: Module , string:: String , name:: String ,
1125
1140
pos:: Int , separatorpos:: Int , startpos:: Int ;
@@ -1130,7 +1145,7 @@ function complete_identifiers!(suggestions::Vector{Completion},
1130
1145
complete_keyword! (suggestions, name)
1131
1146
complete_keyval! (suggestions, name)
1132
1147
end
1133
- if separatorpos > 1 && (string[separatorpos] == ' . ' || string[ separatorpos] == ' : ' )
1148
+ if separatorpos > 1 && in_scope_of_prefix (string, pos, separatorpos)
1134
1149
s = string[1 : prevind (string, separatorpos)]
1135
1150
# First see if the whole string up to `pos` is a valid expression. If so, use it.
1136
1151
prefix = Meta. parse (s, raise= false , depwarn= false )
0 commit comments