Skip to content

fix(preview): buf can be deleted when preview (e.g. actions.buf_del)#2589

Merged
phanen merged 1 commit intomainfrom
bufdel-preview
Feb 27, 2026
Merged

fix(preview): buf can be deleted when preview (e.g. actions.buf_del)#2589
phanen merged 1 commit intomainfrom
bufdel-preview

Conversation

@phanen
Copy link
Collaborator

@phanen phanen commented Feb 27, 2026

Decoration provider "win" (ns=fzf-lua.preview.extmarks):
Lua: fzf-lua/previewer/builtin.lua:466: Invalid buffer id: 23
stack traceback:
	[C]: in function 'nvim_buf_get_extmarks'
	fzf-lua/previewer/builtin.lua:466: in function 'copy_extmarks'
	fzf-lua/previewer/builtin.lua:489: in function <fzf-lua/previewer/builtin.lua:485>

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug in the fzf-lua previewer that caused errors when a source buffer was deleted while its content was being previewed. By introducing a check for buffer validity, the change prevents crashes and improves the overall stability of the preview functionality, ensuring a smoother user experience.

Highlights

  • Bug Fix: Addressed an issue where deleting a buffer during preview could lead to an 'Invalid buffer id' error, causing a stack trace.
  • Preview Stability: Enhanced the robustness of the previewer by explicitly checking the validity of the source buffer before attempting to copy extmarks.
Changelog
  • lua/fzf-lua/previewer/builtin.lua
    • Added a check using api.nvim_buf_is_valid to ensure the source buffer is still valid before proceeding with extmark operations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a potential crash that can occur in the previewer if the source buffer is deleted before extmarks can be copied. The fix introduces a check using api.nvim_buf_is_valid() to ensure the buffer exists before proceeding. This is a direct and effective solution to prevent the 'Invalid buffer id' error. The change is correct and improves the stability of the preview functionality.

@phanen phanen merged commit 29ee11c into main Feb 27, 2026
10 checks passed
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