Skip to content

Commit d4c6bfc

Browse files
committed
Make file handling more robust
1 parent faba69f commit d4c6bfc

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ JSONRPC = "1.1"
2626
JuliaFormatter = "0.20.0, 0.21, 0.22, 0.23, 1"
2727
PrecompileTools = "1"
2828
StaticLint = "8.0"
29-
JuliaWorkspaces = "4.5"
29+
JuliaWorkspaces = "4.6"
3030
SymbolServer = "8"
3131
Tokenize = "0.5.10"
3232
URIs = "1.3"

src/requests/init.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function initialized_notification(params::InitializedParams, server::LanguageSer
203203

204204
if server.workspaceFolders !== nothing
205205
for i in server.workspaceFolders
206-
files = JuliaWorkspaces.read_path_into_textdocuments(filepath2uri(i))
206+
files = JuliaWorkspaces.read_path_into_textdocuments(filepath2uri(i), ignore_io_errors=true)
207207

208208
for i in files
209209
# This might be a sub folder of a folder that is already watched
@@ -230,7 +230,9 @@ function initialized_notification(params::InitializedParams, server::LanguageSer
230230
error("This should not happen")
231231
end
232232

233-
text_file = JuliaWorkspaces.read_text_file_from_uri(uri)
233+
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
234+
text_file === nothing || continue
235+
234236
server._files_from_disc[uri] = text_file
235237

236238
if !haskey(server._open_file_versions, uri)

src/requests/misc.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ function julia_activateenvironment_notification(params::NamedTuple{(:envPath,),T
9494
error("This should not happen")
9595
end
9696

97-
text_file = JuliaWorkspaces.read_text_file_from_uri(uri)
97+
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
98+
text_file===nothing || continue
99+
98100
server._files_from_disc[uri] = text_file
99101

100102
if !haskey(server._open_file_versions, uri)

src/requests/workspace.jl

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ function workspace_didChangeWatchedFiles_notification(params::DidChangeWatchedFi
1010
uri.scheme=="file" || continue
1111

1212
if change.type == FileChangeTypes.Created || change.type == FileChangeTypes.Changed
13-
text_file = nothing
14-
try
15-
JuliaWorkspaces.read_text_file_from_uri(uri)
16-
catch err
17-
if !(is_walkdir_error(err) || err isa JuliaWorkspaces.JWInvalidFileContent)
18-
rethrow(err)
19-
end
20-
end
13+
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
2114

2215
# First handle case where fild could not be found or has invalid content
2316
if text_file === nothing
@@ -191,7 +184,7 @@ function workspace_didChangeWorkspaceFolders_notification(params::DidChangeWorks
191184
load_folder(wksp, server, added_docs)
192185

193186

194-
files = JuliaWorkspaces.read_path_into_textdocuments(wksp.uri)
187+
files = JuliaWorkspaces.read_path_into_textdocuments(wksp.uri, ignore_io_errors=true)
195188

196189
for i in files
197190
# This might be a sub folder of a folder that is already watched

0 commit comments

Comments
 (0)