Skip to content

Commit bad360d

Browse files
committed
Copy project files tracking code into function
1 parent 0da181a commit bad360d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/requests/misc.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,41 @@ function julia_activateenvironment_notification(params::NamedTuple{(:envPath,),T
117117
end
118118
end
119119

120+
function track_project_files!(server::LanguageServerInstance)
121+
# Add project files separately in case they are not in a workspace folder
122+
if server.env_path != ""
123+
for file in ["Project.toml", "JuliaProject.toml", "Manifest.toml", "JuliaManifest.toml"]
124+
file_full_path = joinpath(server.env_path, file)
125+
uri = filepath2uri(file_full_path)
126+
if isfile(file_full_path)
127+
@static if Sys.iswindows()
128+
# Normalize drive letter to lowercase
129+
if length(file_full_path) > 1 && isletter(file_full_path[1]) && file_full_path[2] == ':'
130+
file_full_path = lowercasefirst(file_full_path)
131+
end
132+
end
133+
# Only add again if outside of the workspace folders
134+
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
135+
if haskey(server._files_from_disc, uri)
136+
error("This should not happen")
137+
end
138+
139+
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
140+
text_file === nothing && continue
141+
142+
server._files_from_disc[uri] = text_file
143+
144+
if !haskey(server._open_file_versions, uri)
145+
JuliaWorkspaces.add_file!(server.workspace, text_file)
146+
end
147+
end
148+
# But we do want to track, in case the workspace folder is removed
149+
push!(server._extra_tracked_files, filepath2uri(file_full_path))
150+
end
151+
end
152+
end
153+
end
154+
120155
julia_refreshLanguageServer_notification(_, server::LanguageServerInstance, conn) =
121156
trigger_symbolstore_reload(server)
122157

0 commit comments

Comments
 (0)