Skip to content

Commit a28ea47

Browse files
committed
Fixed Windows path support
1 parent 4f42f27 commit a28ea47

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/luau-lsp-plugin.luau

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ local function GetLibraries(RelativeTo: string, _Libraries, _Uri: Uri?)
1616
local Libraries = (_Libraries or {})
1717
local Uri = (_Uri or lsp.workspace.getRootUri())
1818

19+
RelativeTo = string.gsub(RelativeTo, "[/\\]", "/")
20+
1921
for _, Entry in lsp.fs.listDirectory(Uri) do
2022
local Name = string.sub(Entry:toString(), #Uri:toString() + 2)
2123
local Library = string.match(Name, "(.*)%.meta%.json$")
2224

2325
if Library and IsLibrary(Entry) then
2426
local FixedPath = Entry.path
2527

28+
FixedPath = string.gsub(FixedPath, "[/\\]", "/")
29+
30+
if string.find(FixedPath, "^/?%a:") then
31+
FixedPath = string.sub(FixedPath, 2)
32+
end
33+
2634
for _, Directory in ipairs(string.split(RelativeTo, "/")) do
2735
if string.find(FixedPath, `{Directory}/`, 1, true) == 1 then
2836
FixedPath = string.sub(FixedPath, #Directory + 2)
@@ -48,7 +56,7 @@ return {
4856
local Changes = {}
4957
local Line, LineStart = 1, 1
5058

51-
local Libraries = GetLibraries((string.gsub(Context.filePath, "/[^/]-$", "")))
59+
local Libraries = GetLibraries((string.gsub(Context.filePath, "[/\\][^/\\]-$", "")))
5260

5361
for Index = 1, #Source do
5462
if string.sub(Source, Index, Index) == "\n" then

0 commit comments

Comments
 (0)