nvim-neorg / neorg-telescope

Telescope.nvim integration for Neorg
GNU General Public License v3.0
187 stars 24 forks source link

fix: nil check entry.path #71

Closed benlubas closed 2 months ago

benlubas commented 2 months ago

from the issue discussed on discord.

Here's some context from discord:

It looks like linking to the same file might cause problems? Like, I can see that generate_links() is able to pass nil as the file to get_linkables() here:

local file_inserted = (function()
    if vim.api.nvim_get_current_buf() == bufnr then
        return nil
    else
        return Path(file)
    end
end)()
local links = get_linkables(bufnr, file_inserted, Path(current_workspace[2]))
local function get_linkables(bufnr, file, workspace)
    local ret = {}

    local path
    local lines
    if file then
        lines = vim.fn.readfile(file:tostring("/"))
        path = file
        file = "$/" .. file:relative_to(workspace):remove_suffix(".norg")
    else
        lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
    end
--- ...
        table.insert(
            ret,
            { line = i, linkable = marker_or_drawer[2], display = marker_or_drawer[1], file = file, path = path }
        )
    end
end
return ret

And then those values are the values passed to entry maker I think?

benlubas commented 2 months ago

both are absolute paths, yes

max397574 commented 2 months ago

thank you