Skip to content

Commit 1076f09

Browse files
fix: incorrect file names in doc.json
File names in doc.json were broken since #2821. See discussion #2971.
1 parent 115a518 commit 1076f09

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

script/cli/doc/export.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ local getLabel = require 'core.hover.label'
88
local jsonb = require 'json-beautify'
99
local util = require 'utility'
1010
local markdown = require 'provider.markdown'
11+
local fs = require 'bee.filesystem'
12+
local furi = require 'file-uri'
1113

1214
---@alias doctype
1315
---| 'doc.alias'
@@ -55,13 +57,12 @@ local markdown = require 'provider.markdown'
5557
local export = {}
5658

5759
function export.getLocalPath(uri)
58-
--remove uri root (and prefix)
59-
local local_file_uri = uri
60-
local i, j = local_file_uri:find(DOC)
61-
if not j then
62-
return '[FOREIGN] '..uri
60+
local relativePath = fs.relative(furi.decode(uri), DOC):string()
61+
if relativePath:sub(1, 2) == '..' then
62+
-- not under project directory
63+
return '[FOREIGN] ' .. uri
6364
end
64-
return local_file_uri:sub( j + 1 )
65+
return relativePath
6566
end
6667

6768
function export.positionOf(rowcol)

0 commit comments

Comments
 (0)