diff --git a/src/REPLMode/command_declarations.jl b/src/REPLMode/command_declarations.jl index e340cda294..bb1fd4190c 100644 --- a/src/REPLMode/command_declarations.jl +++ b/src/REPLMode/command_declarations.jl @@ -207,7 +207,7 @@ PSA[:name => "free", PSA[:name => "all", :api => :all_pkgs => true], ], :arg_parser => parse_package, - :completions => complete_installed_packages, + :completions => complete_fixed_packages, :description => "undoes a `pin`, `develop`, or stops tracking a repo", :help => md""" free pkg[=uuid] ... diff --git a/src/REPLMode/completions.jl b/src/REPLMode/completions.jl index 078b083d6c..dbc6581406 100644 --- a/src/REPLMode/completions.jl +++ b/src/REPLMode/completions.jl @@ -127,6 +127,15 @@ function complete_installed_packages_and_compat(options, partial) end end +function complete_fixed_packages(options, partial) + env = try EnvCache() + catch err + err isa PkgError || rethrow() + return String[] + end + return unique!([entry.name for (uuid, entry) in env.manifest.deps if Operations.isfixed(entry)]) +end + function complete_add_dev(options, partial, i1, i2) comps, idx, _ = complete_local_dir(partial, i1, i2) if occursin(Base.Filesystem.path_separator_re, partial) diff --git a/test/repl.jl b/test/repl.jl index 542baffbd0..17bcfe0395 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -334,6 +334,8 @@ temp_pkg_dir() do project_path; cd(project_path) do @test isempty(c) c, r = test_complete("rm --project Exam") @test isempty(c) + c, r = test_complete("free PackageWithDep") + @test "PackageWithDependency" in c # given this was devved c, r = test_complete("rm -m PackageWithDep") @test "PackageWithDependency" in c @@ -363,6 +365,12 @@ temp_pkg_dir() do project_path; cd(project_path) do @test "remove" in c @test apply_completion("rm E") == "rm Example" @test apply_completion("add Exampl") == "add Example" + c, r = test_complete("free Exa") + @test isempty(c) # given this was added i.e. not fixed + pkg"pin Example" + c, r = test_complete("free Exa") + @test "Example" in c + pkg"free Example" # help mode @test apply_completion("?ad") == "?add"