Skip to content

Commit 6a66fb9

Browse files
committed
Substitute by function calls
1 parent bad360d commit 6a66fb9

File tree

2 files changed

+2
-57
lines changed

2 files changed

+2
-57
lines changed

src/requests/init.jl

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -245,38 +245,7 @@ function initialized_notification(params::InitializedParams, server::LanguageSer
245245
end
246246
end
247247

248-
# Add project files separately in case they are not in a workspace folder
249-
if server.env_path != ""
250-
for file in ["Project.toml", "JuliaProject.toml", "Manifest.toml", "JuliaManifest.toml"]
251-
file_full_path = joinpath(server.env_path, file)
252-
uri = filepath2uri(file_full_path)
253-
if isfile(file_full_path)
254-
@static if Sys.iswindows()
255-
# Normalize drive letter to lowercase
256-
if length(file_full_path) > 1 && isletter(file_full_path[1]) && file_full_path[2] == ':'
257-
file_full_path = lowercasefirst(file_full_path)
258-
end
259-
end
260-
# Only add again if outside of the workspace folders
261-
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
262-
if haskey(server._files_from_disc, uri)
263-
error("This should not happen")
264-
end
265-
266-
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
267-
text_file === nothing && continue
268-
269-
server._files_from_disc[uri] = text_file
270-
271-
if !haskey(server._open_file_versions, uri)
272-
JuliaWorkspaces.add_file!(server.workspace, text_file)
273-
end
274-
end
275-
# But we do want to track, in case the workspace folder is removed
276-
push!(server._extra_tracked_files, filepath2uri(file_full_path))
277-
end
278-
end
279-
end
248+
track_project_files!(server)
280249

281250
JuliaWorkspaces.set_input_fallback_test_project!(server.workspace.runtime, isempty(server.env_path) ? nothing : filepath2uri(server.env_path))
282251

src/requests/misc.jl

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,7 @@ function julia_activateenvironment_notification(params::NamedTuple{(:envPath,),T
8282

8383
empty!(server._extra_tracked_files)
8484

85-
# Add project files separately in case they are not in a workspace folder
86-
if server.env_path != ""
87-
for file in ["Project.toml", "JuliaProject.toml", "Manifest.toml", "JuliaManifest.toml"]
88-
file_full_path = joinpath(server.env_path, file)
89-
uri = filepath2uri(file_full_path)
90-
if isfile(file_full_path)
91-
# Only add again if outside of the workspace folders
92-
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
93-
if haskey(server._files_from_disc, uri)
94-
error("This should not happen")
95-
end
96-
97-
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
98-
text_file===nothing || continue
99-
100-
server._files_from_disc[uri] = text_file
101-
102-
if !haskey(server._open_file_versions, uri)
103-
JuliaWorkspaces.add_file!(server.workspace, text_file)
104-
end
105-
end
106-
push!(server._extra_tracked_files, filepath2uri(file_full_path))
107-
end
108-
end
109-
end
85+
track_project_files!(server)
11086

11187
JuliaWorkspaces.set_input_fallback_test_project!(server.workspace.runtime, isempty(server.env_path) ? nothing : filepath2uri(server.env_path))
11288

0 commit comments

Comments
 (0)