Skip to content

Commit

Permalink
fix: roslyn doesn't attach to cs buffer when .sln is not present
Browse files Browse the repository at this point in the history
The condition `not sln or not csproj` in sln.utils.root_dir
was causing roslyn not to attach to cs buffer if one of
.csproj or .sln was not found via `vim.fs.root_dir`

This behavior was introduced relatively recently in
d121ca7

The fix updates the condition to allow for only one of these being
found (the rest of the code already seems to account for it). After
updating the condition, find_files_with_extension(sln, ".sln") was
breaking as well, so I wrapped those calls in their own separate
conditions based on if .csproj or .sln root directories were found.

Existing github issue: seblyng#87

address pr feedback: early return on no sln
  • Loading branch information
mparq committed Nov 19, 2024
1 parent 2b2f57b commit b4d7722
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/roslyn/sln/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,23 @@ function M.root_dir(buffer, broad_search)
return name:match("%.csproj$") ~= nil
end)

if not sln or not csproj then
if not sln and not csproj then
return {}
end

local projects = csproj and { files = find_files_with_extension(csproj, ".csproj"), directory = csproj } or nil

if not sln then
return {
solutions = nil,
projects = projects,
}
end

if broad_search then
local solutions = vim.fs.find(function(name, _)
return name:match("%.sln$")
end, { type = "file", limit = math.huge, path = sln })

return {
solutions = solutions,
projects = projects,
Expand Down

0 comments on commit b4d7722

Please sign in to comment.