Skip to content

fix(file): suppress FileType during synthetic BufReadPost#116

Merged
dlyongemallo merged 1 commit intomainfrom
113-fix_async_keymap_treesitter
Apr 15, 2026
Merged

fix(file): suppress FileType during synthetic BufReadPost#116
dlyongemallo merged 1 commit intomainfrom
113-fix_async_keymap_treesitter

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

@dlyongemallo dlyongemallo commented Apr 15, 2026

Fixes #113.

Copilot AI review requested due to automatic review settings April 15, 2026 07:38
Copy link
Copy Markdown

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 fixes a folding regression triggered by synthetic BufReadPost emission in File:attach_buffer() by preventing Neovim’s filetypedetect augroup from indirectly re-firing FileType, which can cause user FileType autocmds (e.g., treesitter folding setup) to override Diffview’s window-local options (ref #113).

Changes:

  • Temporarily appends FileType to eventignore while executing the synthetic BufReadPost autocmd for diff buffers.
  • Refactors the BufReadPost emission guard into a local should_emit_buf_read boolean for readability.
  • Adds/updates functional tests to cover: skipping emission when diffview_disable_ts is set, emitting only once across repeated attaches, suppressing FileType, and restoring eventignore.

Reviewed changes

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

File Description
lua/diffview/vcs/file.lua Suppresses FileType during the synthetic BufReadPost to prevent folding/window-option clobbering.
lua/diffview/tests/functional/keymap_save_spec.lua Adds regression and safety tests for BufReadPost emission behavior and eventignore restoration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dlyongemallo dlyongemallo merged commit 88623be into main Apr 15, 2026
6 checks passed
@dlyongemallo dlyongemallo deleted the 113-fix_async_keymap_treesitter branch April 15, 2026 17:01
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.

[Bug] Folding broken by #106 when treesitter folding enabled

2 participants