diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index f07b8d454cce4..cd9c4a0eb4b49 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -111,7 +111,7 @@ function complete_path(path::AbstractString, pos; use_envpath=false) dir, prefix = splitdir(path) end local files - try +# try if isempty(dir) files = readdir() elseif isdir(dir) @@ -119,14 +119,14 @@ function complete_path(path::AbstractString, pos; use_envpath=false) else return String[], 0:-1, false end - catch - return String[], 0:-1, false - end +# catch +# return String[], 0:-1, false +# end matches = Set{String}() for file in files if startswith(file, prefix) - id = try isdir(joinpath(dir, file)) catch; false end + id = isdir(joinpath(dir, file)) # joinpath is not used because windows needs to complete with double-backslash push!(matches, id ? file * (@static is_windows() ? "\\\\" : "/") : file) end @@ -138,12 +138,12 @@ function complete_path(path::AbstractString, pos; use_envpath=false) for pathdir in pathdirs local actualpath - try +# try actualpath = realpath(pathdir) - catch +# catch # Bash doesn't expect every folder in PATH to exist, so neither shall we - continue - end +# continue +# end if actualpath != pathdir && in(actualpath,pathdirs) # Remove paths which (after resolving links) are in the env path twice. @@ -152,17 +152,17 @@ function complete_path(path::AbstractString, pos; use_envpath=false) end local filesinpath - try +# try filesinpath = readdir(pathdir) - catch e +# catch e # Bash allows dirs in PATH that can't be read, so we should as well. - if isa(e, SystemError) - continue - else +# if isa(e, SystemError) + # continue + # else # We only handle SystemErrors here - rethrow(e) - end - end + # rethrow(e) +# end +# end for file in filesinpath # In a perfect world, we would filter on whether the file is executable diff --git a/test/replcompletions.jl b/test/replcompletions.jl index 1b9ee804bd6e5..574c0b5bf75a6 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -634,9 +634,13 @@ if is_windows() file = basename(tmp) temp_name = basename(path) cd(path) do + @test isdir(path) + @test !isempty(path) + readdir(path) + s = "cd ..\\\\" c,r = test_scomplete(s) - @test r == length(s)+1:length(s) + @test r == length(s)+1+0:length(s) @test temp_name * "\\\\" in c s = "ls $(file[1:2])"