Skip to content

Commit

Permalink
Windows debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Oct 10, 2016
1 parent e062942 commit 9ec527e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
34 changes: 17 additions & 17 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ 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)
files = readdir(dir)
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
Expand All @@ -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.
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])"
Expand Down

0 comments on commit 9ec527e

Please sign in to comment.