chipsenkbeil / org-roam.nvim

Port of org-roam to neovim using orgmode
MIT License
107 stars 9 forks source link

[bug] Wrong refile path when capture on Windows #32

Closed KortanZ closed 5 months ago

KortanZ commented 5 months ago

Thank you for this awesome plugin. This problem is a Windows specific problem I guess and I don't know if this problem is related to nvim-orgmode/orgmode plugin. I'v tested nvim-orgmode/orgmode 's capture, and it works well.

When config org-roam directory as absolute path, the capture mode seems to generate wrong refile path.

-- orgmode
require('orgmode').setup({
  org_agenda_files = {"D:\\doc\\org\\*"}, 
  org_default_notes_file = "D:\\doc\\org\\refile.org",
})
-- org-roam
require("org-roam").setup({
  directory = "D:\\doc\\org\\roam",
})

When press <leader>nc enter capture mode set node name and wq, it will prompt Refile destination D:/doc/org/roam\D:documents/org/roam\20240430102233-roam_test.org dose not exist, Create now?. This file path seems like join the directory twice and when second joint, missing a slash after D:.

When config directory as relative path

require("org-roam").setup({
  directory = "roam",
})

When :pwd echos D:\some_code_base. The refile path is D:\some_code_base\roam\roam\20240430102233-roam_test.org, it joint path twice too.

chipsenkbeil commented 5 months ago

Hm, your separator is both / and \. I also don't know why it's appending roam twice. The Windows run of tests didn't have any problems with joining. The org roam directory definitely needs to be absolute, either something like /path/to/roam or ~/roam. But not sure why there are two path separators in the first example, or why roam appears twice in the second.

I also just noticed another odd thing about the refile path:

D:/doc/org/roam\D:documents/org/roam\20240430102233-roam_test.org

The second path (presumably joining two absolute paths together) is D:documents/.... So it's missing the \\ following the drive.

KortanZ commented 5 months ago

The second path (presumably joining two absolute paths together) is D:documents/.... So it's missing the \ following the drive.

Yes. It's missing some slash or backslash. So i wander there may some path join problem.

The Windows run of tests didn't have any problems with joining.

If you could not reproduce this problem, I can help to debug, but need a little help with where the path join happened. A brief call route is enough.

chipsenkbeil commented 5 months ago

@KortanZ try pulling the latest commit. I booted up an old Windows vm and was able to reproduce, but with the latest commit it seems to go away.

[UPDATE] I also found one more issue on windows, which was that the node IDs had \r at the end when parsing them from org documents. That should be fixed in the latest commit. I can now verify that I can capture, insert, and navigate nodes on my windows vm.

KortanZ commented 5 months ago

@chipsenkbeil Now it works like a charm. Thank you!

Btw, I've also tested relative path(which is illegal as you told), the twice-join problem still, but i think we can safely ignore that if there is no other side effect.