Skip to content

fix: don't call load_oil_buffer in open_preview if oil_ready is not set - #769

Open
FelipeSharkao wants to merge 1 commit into
stevearc:masterfrom
FelipeSharkao:fix/632
Open

fix: don't call load_oil_buffer in open_preview if oil_ready is not set#769
FelipeSharkao wants to merge 1 commit into
stevearc:masterfrom
FelipeSharkao:fix/632

Conversation

@FelipeSharkao

Copy link
Copy Markdown

Based on the fix in barrettruth#12.

In their words:

When the preview window opens a directory that already has a loaded oil buffer with unsaved edits, open_preview() unconditionally calls load_oil_buffer() on it. This re-initializes the buffer via view.initialize() → render_buffer_async(), which re-fetches the directory listing from disk and replaces all buffer lines, destroying the user's pending edits (e.g. a cut line). The mutation parser then can't see the deleted entry in the source buffer, producing a COPY action instead of a MOVE.

[...]

Guard the load_oil_buffer() call in open_preview() with a check for vim.b[filebufnr].oil_ready. Buffers that are already initialized and rendered skip re-loading, preserving any unsaved modifications.

I verified the fix manually, though I did not do an in-depth analysis to see if this breaks anything else.

Closes #632

FelipeSharkao added a commit to FelipeSharkao/Settings that referenced this pull request Jul 17, 2026
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: Moving a file with previewer opened will copy instead

1 participant