fix: reimplement section luals.config in doc.json#3072
Conversation
Section luals.config was implemented in LuaLS#2562, but got lost after a major refactoring in LuaLS#2821. This commit reimplements it. See discussion LuaLS#2963.
script/cli/doc/export.lua
Outdated
| return { | ||
| name = 'LuaLS', | ||
| type = 'luals.config', | ||
| DOC = fs.absolute(fs.path(DOC)):string(), |
There was a problem hiding this comment.
As I found out here: #3068
- that
fs.absolutereturns an not necessarily canonical absolute path - which means it can still contain
./.. - if
DOCis passed as., then this final path string will be something like/some/path/.
maybe what you want is fs.canonical instead? 🤔
also I think this problem exists in the script/cli/doc/init.lua
=> might need to change those fs.absolute to fs.canonical?
There was a problem hiding this comment.
Yes, using fs.canonical seems to be the better way to go. I've changed it.
Just a few notes on fs.absolute() vs. fs.canonical() that tricked me:
-
While a trailing slash in the path name survives with
fs.absolute(), it is stripped withfs.canonical(). Interestingly the trailing slash was mostly an issue on Windows, but not on Linux. -
I am running Windows in a virtual machine with a Linux host. And the test files I used were on a Linux filesystem that was shared as drive
F:in Windows. Whilefs.absolute()returnedF:/proj/test/...on Windows,fs.canonical()returned//VBoxSvr/proj/test/..., even if the paths were the same. This is just a reminder not to mixfs.absolute()andfs.canonical()carelessly.
Fixes #2963
Reimplements section
luals.configin file doc.json that was missing since #2821.