Skip to content

fix(links): Skip links without a url - #1186

Open
seflue wants to merge 1 commit into
nvim-orgmode:masterfrom
seflue:fix/empty-link-nil-url
Open

seflue wants to merge 1 commit into
nvim-orgmode:masterfrom
seflue:fix/empty-link-nil-url

Conversation

@seflue

@seflue seflue commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Typing [[]] into an org file, for example while starting a link, breaks every caller of OrgFile:get_links() until the brackets are filled:

vim/treesitter.lua:179: attempt to index local 'node' (a nil value)
  in function 'get_node_text'
  lua/orgmode/org/links/hyperlink.lua:53: in function 'from_node'
  lua/orgmode/files/file.lua: in function 'get_links'

The grammar still produces a link node for the empty brackets, but without a url field. Same for [[][desc]].

from_node now returns nil for a link node without a url. get_links skips those nodes; the at_cursor callers already handle nil.

An empty link like [[]] parses into a link node without a url
field. Collecting links from such a file crashed on reading the
missing node instead of ignoring the malformed link.

Treat a link node without a url as no link: skip it in the
file-level link list and return nil from the cursor lookup,
whose callers already handle nil.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant