Skip to content

Commit 38d2b36

Browse files
Make leading ] fix silent, and not during completions (#4328)
1 parent 0e123a2 commit 38d2b36

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

ext/REPLExt/completions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ end
249249
function _completions(input, final, offset, index; hint::Bool)
250250
statement, word_count, partial = nothing, nothing, nothing
251251
try
252-
words = tokenize(input)[end]
252+
words = tokenize(input; rm_leading_bracket = false)[end]
253253
word_count = length(words)
254254
statement, partial = core_parse(words)
255255
if final

src/REPLMode/REPLMode.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ function lex(cmd::String)::Vector{QString}
228228
return filter(x -> !isempty(x.raw), qstrings)
229229
end
230230

231-
function tokenize(cmd::AbstractString)
231+
function tokenize(cmd::AbstractString; rm_leading_bracket::Bool = true)
232232
cmd = replace(replace(cmd, "\r\n" => "; "), "\n" => "; ") # for multiline commands
233-
if startswith(cmd, ']')
234-
@warn "Removing leading `]`, which should only be used once to switch to pkg> mode"
233+
if rm_leading_bracket && startswith(cmd, ']')
235234
cmd = string(lstrip(cmd, ']'))
236235
end
237236
qstrings = lex(cmd)

test/repl.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ using ..Utils
2626
end
2727

2828
@testset "accidental" begin
29-
@test_logs (:warn, r"Removing leading.*") pkg"]?"
30-
@test_logs (:warn, r"Removing leading.*") pkg"] ?"
31-
@test_logs (:warn, r"Removing leading.*") pkg"]st"
32-
@test_logs (:warn, r"Removing leading.*") pkg"] st"
33-
@test_logs (:warn, r"Removing leading.*") pkg"]st -m"
34-
@test_logs (:warn, r"Removing leading.*") pkg"] st -m"
35-
@test_logs (:warn, r"Removing leading.*") pkg"]" # noop
29+
pkg"]?"
30+
pkg"] ?"
31+
pkg"]st"
32+
pkg"] st"
33+
pkg"]st -m"
34+
pkg"] st -m"
35+
pkg"]" # noop
3636
end
3737

3838
temp_pkg_dir() do project_path

0 commit comments

Comments
 (0)