Skip to content

fix(footnotes): add nil check in goto_definition navigation#208

Merged
YousefHadder merged 5 commits intomainfrom
fix/footnotes-navigation-nil-check
Feb 8, 2026
Merged

fix(footnotes): add nil check in goto_definition navigation#208
YousefHadder merged 5 commits intomainfrom
fix/footnotes-navigation-nil-check

Conversation

@YousefHadder
Copy link
Copy Markdown
Owner

Add a defensive nil check in footnotes/navigation.lua goto_definition() after nvim_buf_get_lines().

If the buffer changes between parsing and cursor movement (e.g., via autocmd or async operation), line could be nil causing a crash on the subsequent line:find() call. The nil guard falls back to jumping to column 0 of the definition line.

Copilot AI review requested due to automatic review settings February 8, 2026 18:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a defensive guard in the footnotes navigation flow to avoid a crash when nvim_buf_get_lines() returns no line (e.g., after buffer changes), improving the robustness of goto_definition() in the footnotes feature.

Changes:

  • Add a nil check for the fetched definition line before calling line:find()
  • Add a fallback cursor jump to column 0 when the definition line cannot be read

Copilot AI review requested due to automatic review settings February 8, 2026 19:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings February 8, 2026 19:08
@YousefHadder YousefHadder merged commit 438ea47 into main Feb 8, 2026
19 checks passed
@YousefHadder YousefHadder deleted the fix/footnotes-navigation-nil-check branch February 8, 2026 19:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

2 participants