jbyuki / one-small-step-for-vimkind

Debug adapter for Neovim plugins
MIT License
396 stars 10 forks source link

Possible way to resolve symlink issue #19

Closed yioneko closed 1 year ago

yioneko commented 1 year ago

I see that document has suggested opening file in symlinked position to solve the problem: https://github.com/jbyuki/one-small-step-for-vimkind/blob/0e87072a558acc003033e29b1e1b1d315a74bd55/doc/osv.txt#L181-L189

But actually it should not work since (neo)vim will auto resolve the symlink when opening the file: https://github.com/vim/vim/issues/4942

And i've tried the following patch to always resolve link, which works for me:

diff --git a/lua/osv/init.lua b/lua/osv/init.lua
index 7fd405f..a6c5cc8 100644
--- a/lua/osv/init.lua
+++ b/lua/osv/init.lua
@@ -332,7 +332,7 @@ function M.wait_attach()
         if info.source:sub(1, 1) == '@' then
           stack_frame.source = {
             name = info.source,
-            path = vim.fn.fnamemodify(info.source:sub(2), ":p"),
+            path = vim.fn.resolve(vim.fn.fnamemodify(info.source:sub(2), ":p")),
           }
           stack_frame.line = info.currentline 
           stack_frame.column = 0
@@ -517,6 +517,7 @@ function M.wait_attach()
           local path = source_path:sub(2)
           local succ, path = pcall(vim.fn.fnamemodify, path, ":p")
           if succ then
+            path = vim.fn.resolve(path)
             path = vim.uri_from_fname(path:lower())
             if bps[path] then
               log("breakpoint hit")

Hope this will give help for a better solution.

jbyuki commented 1 year ago

This will surely help a lot of people, thank you!