fix(preview): prevent preview from re-initializing modified oil buffers (#12)
Problem: 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. The mutation parser then can't see the deleted entry in the source buffer, so it produces a COPY action instead of a MOVE. Solution: 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 are not re-loaded, preserving any unsaved modifications the user has made. Closes: stevearc/oil.nvim#632
This commit is contained in:
parent
70861e5896
commit
fe16993262
1 changed files with 1 additions and 1 deletions
|
|
@ -602,7 +602,7 @@ M.open_preview = function(opts, callback)
|
|||
|
||||
-- If we called open_preview during an autocmd, then the edit command may not trigger the
|
||||
-- BufReadCmd to load the buffer. So we need to do it manually.
|
||||
if util.is_oil_bufnr(filebufnr) then
|
||||
if util.is_oil_bufnr(filebufnr) and not vim.b[filebufnr].oil_ready then
|
||||
M.load_oil_buffer(filebufnr)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue