LuaLS / LuaLS/lua-language-server

Renamed file considered deleted inside directory junction

Đang mở
#3,279 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Windows

What is the issue affecting?

Other

Expected Behaviour

LS correctly works with files inside directory junction or symlinks.

Actual Behaviour

LS functionality stops working after saving such a file in editor.

Reproduction steps
  1. Enable LuaLS in NeoVim.
  2. Put NeoVim config files inside directory junction. E.g. I have init.lua file in directory C:\dev\dotfiles\nvim and I've created the junction to that directory in C:\Users\RobotComp.ru\AppData\Local\nvim. NVim reads config files from C:\Users\RobotComp.ru\AppData\Local\nvim.
  3. Open init.lua in NVim, change something and save it with :w command.
  4. After that, any interactions with LS stop working (hover, go to definition, etc.)
  5. If I re-edit file with :e % command, everything starts working again.
Additional Notes

I did some research and found the following.

When saving init.lua, NVim renames it several times (to init.lua~ and back). Don't know why.
The logs (see error.log) show that the filewatch(rename) function is called on LS, which calls isExists().
And although the file exists, isExists() returns false, so the file is considered deleted, and the LS "forgets" about it.

More specifically, the problem occurs in script/filewatch.lua:18:

if res :string():gsub('^%w+:', string.lower)
~= path:string():gsub('^%w+:', string.lower) then
return false
end

Here, it turns out that res contains the actual path to the file (C:\dev\dotfiles\nvim\init.lua), and path contains the path with the junction (C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua).

Commenting out these lines makes everything work correctly (see fixed.log). However, I didn't make a PR with such changes because I didn't fully understand why this path comparison was needed at all. It seems like it fixes some other bug?

Thanks in advance :)

Log File

[00:20:20.415][debug][#0:script\filewatch.lua:98]: filewatch: rename C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua
[00:20:20.415][debug][#0:script\filewatch.lua:98]: filewatch: modify C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua
[00:20:20.415][debug][#0:script\filewatch.lua:98]: filewatch: rename C:\Users\RobotComp.ru\AppData\Local\nvim\init.lua~
[00:20:20.415][debug][#0:script\workspace\workspace.lua:592]: FileChangeType.Deleted file:///c%3A/Users/RobotComp.ru/AppData/Local/nvim/init.lua
[00:20:20.416][debug][#0:script\workspace\workspace.lua:592]: FileChangeType.Deleted file:///c%3A/Users/RobotComp.ru/AppData/Local/nvim/init.lua~

error.log
fixed.log

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện vấn đề trên Windows với một cấu hình NeoVim được lưu thông qua một directory junction, sau đó đọc script/filewatch.lua:18 và theo dõi cách xử lý việc đổi tên được thể hiện trong các log. Được xem là hoàn tất khi việc lưu init.lua không còn khiến language server coi đường dẫn junction là đã bị xóa, trong khi hover và go-to-definition vẫn tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
lua, neovim
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.