diff --git a/lua/orgmode/org/hyperlinks/url.lua b/lua/orgmode/org/hyperlinks/url.lua index cc7ea900e..ac1575f33 100644 --- a/lua/orgmode/org/hyperlinks/url.lua +++ b/lua/orgmode/org/hyperlinks/url.lua @@ -7,6 +7,7 @@ local fs = require('orgmode.utils.fs') ---@field protocol string ---@field path string ---@field path_type OrgUrlPathType +---@field realpath string ---@field target { type: OrgUrlTargetType, value: string | number | nil } local Url = {} Url.__index = Url diff --git a/tests/plenary/helpers.lua b/tests/plenary/helpers.lua index 9df05d9f8..91886eff1 100644 --- a/tests/plenary/helpers.lua +++ b/tests/plenary/helpers.lua @@ -35,8 +35,10 @@ local function create_file_instance(lines, filename) return file end +---@param fixtures {filename: string, content: string[] }[] +---@param config table? ---@return table -local function create_agenda_files(filenames, contents) +local function create_agenda_files(fixtures, config) -- NOTE: content is only 1 line for 1 file local temp_fname = vim.fn.tempname() local temp_dir = vim.fn.fnamemodify(temp_fname, ':p:h') @@ -44,20 +46,20 @@ local function create_agenda_files(filenames, contents) vim.fn.delete(temp_dir .. '/*', 'rf') local files = {} local agenda_files = {} - for i, filename in ipairs(filenames) do - local fname = temp_dir .. '/' .. filename + for _, fixture in pairs(fixtures) do + local fname = temp_dir .. '/' .. fixture.filename fname = vim.fn.fnamemodify(fname, ':p') if fname then local dir = vim.fn.fnamemodify(fname, ':p:h') vim.fn.mkdir(dir, 'p') - vim.fn.writefile({ contents[i] }, fname) - files[filename] = fname + vim.fn.writefile(fixture.content, fname) + files[fixture.filename] = fname table.insert(agenda_files, fname) end end local cfg = vim.tbl_extend('force', { org_agenda_files = agenda_files, - }, {}) + }, config or {}) local org = orgmode.setup(cfg) org:init() return files diff --git a/tests/plenary/org/autocompletion_spec.lua b/tests/plenary/org/autocompletion_spec.lua index 4465eaa90..7331b2d28 100644 --- a/tests/plenary/org/autocompletion_spec.lua +++ b/tests/plenary/org/autocompletion_spec.lua @@ -340,13 +340,16 @@ describe('Autocompletion', function() }, result) end) - it('should work on relative paths', function() + it('should work on relative paths targeting parent directory', function() local files = helpers.create_agenda_files({ - 'a.org', - 'b/c.org', - }, { - '[[./ ', - '[[../ ', + { + filename = 'a.org', + content = { '' }, + }, + { + filename = 'b/c.org', + content = { '[[../' }, + }, }) helpers.load_file(files['b/c.org']) vim.fn.cursor({ 1, 6 }) @@ -356,13 +359,17 @@ describe('Autocompletion', function() { menu = '[Org]', word = '../b/c.org' }, }, org.completion:omnifunc(0, '../')) end) - it('should work on relative paths', function() + + it('should work on relative paths targeting current directory', function() local files = helpers.create_agenda_files({ - 'a.org', - 'b/c.org', - }, { - '[[./ ', - '[[../ ', + { + filename = 'a.org', + content = { '[[./' }, + }, + { + filename = 'b/c.org', + content = { '' }, + }, }) helpers.load_file(files['a.org']) vim.fn.cursor({ 1, 5 })