Skip to content

fix: crash on case-only filename renames (case-insensitive filesystems) - #779

Closed
theAnuragMishra wants to merge 0 commit into
stevearc:masterfrom
theAnuragMishra:master
Closed

theAnuragMishra wants to merge 0 commit into
stevearc:masterfrom
theAnuragMishra:master

Conversation

@theAnuragMishra

@theAnuragMishra theAnuragMishra commented Sep 3, 2026 •

Copy link
Copy Markdown

Renaming a file via oil where only the case changes (test.java ->
Test.java) throws invalid buffer error on a case-insensitive filesystem, but only if the file was already
open in a buffer.

Cause:
vim.fn.bufadd(dest_buf_name) resolves to the same buffer as
src_bufnr when the two names differ only in case, since they point
to the same inode. rename_buffer's swap logic assumes src_bufnr
and dest_bufnr are always distinct, so it deletes src_bufnr and
then accesses dest_bufnr (the now-deleted same buffer) right after.

Fix:
Short-circuit when dest_bufnr == src_bufnr: just rename the buffer
in place and clean up the old-name buffer.

fixes #778

@github-actions
github-actions Bot requested a review from stevearc September 3, 2026 09:59
@theAnuragMishra

Copy link
Copy Markdown
Author

@stevearc can you check this out?

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: invalid buffer error on renaming

1 participant