From 1ee6c6b259721bd047408be0105b11b3fba58d8c Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Fri, 6 Mar 2026 15:19:32 -0500 Subject: [PATCH] feat: add `cleanup_buffers_on_delete` option (#73) Problem: When files are deleted via canola, any open Neovim buffers for those files remain alive, polluting the jumplist with stale entries. Solution: Add an opt-in `cleanup_buffers_on_delete` config option (default `false`). When enabled, `finish()` in `mutator/init.lua` iterates completed delete actions and wipes matching buffers via `nvim_buf_delete` before `CanolaActionsPost` fires. Only local filesystem deletes are handled (guarded by the `files` adapter check). --- doc/canola.txt | 6 + doc/upstream.md | 216 ++++++++++++++++++------------------ lua/canola/config.lua | 4 + lua/canola/mutator/init.lua | 15 +++ spec/files_spec.lua | 43 +++++++ 5 files changed, 176 insertions(+), 108 deletions(-) diff --git a/doc/canola.txt b/doc/canola.txt index 2553b66..641eee5 100644 --- a/doc/canola.txt +++ b/doc/canola.txt @@ -311,6 +311,12 @@ prompt_save_on_select_new_entry *canola.prompt_save_on_select_new_e When this option is `true`, Canola will prompt you to save before entering a file or directory that is pending within canola, but does not exist on disk. +cleanup_buffers_on_delete *canola.cleanup_buffers_on_delete* + type: `boolean` default: `false` + When `true`, canola will wipe any open buffer whose path matches a file that + was successfully deleted via canola. This prevents stale buffers from + appearing in the jumplist after a deletion. + -------------------------------------------------------------------------------- API *canola-api* diff --git a/doc/upstream.md b/doc/upstream.md index b85fa6e..48bf754 100644 --- a/doc/upstream.md +++ b/doc/upstream.md @@ -55,112 +55,112 @@ Bugs fixed in this fork that remain open upstream. cherry-picked PR, `not actionable` = can't/won't fix, `tracking` = known/not yet addressed, `open` = not yet triaged. -| Issue | Status | Notes | -| ------------------------------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [#85](https://github.com/stevearc/oil.nvim/issues/85) | open | Git status column (P2) | -| [#95](https://github.com/stevearc/oil.nvim/issues/95) | open | Undo after renaming files (P1) | -| [#117](https://github.com/stevearc/oil.nvim/issues/117) | open | Move file into new dir via slash in name (P1, related to [#708](https://github.com/stevearc/oil.nvim/pull/708)) | -| [#156](https://github.com/stevearc/oil.nvim/issues/156) | open | Paste path of files into oil buffer (P2) | -| [#200](https://github.com/stevearc/oil.nvim/issues/200) | open | Highlights not working when opening a file (P2) | -| [#207](https://github.com/stevearc/oil.nvim/issues/207) | open | Suppress "no longer available" message (P1) | -| [#210](https://github.com/stevearc/oil.nvim/issues/210) | open | FTP support (P2) | -| [#213](https://github.com/stevearc/oil.nvim/issues/213) | open | Disable preview for large files (P1) | -| [#226](https://github.com/stevearc/oil.nvim/issues/226) | open | K8s/Docker adapter (P2) | -| [#232](https://github.com/stevearc/oil.nvim/issues/232) | open | Cannot close last window (P2) | -| [#254](https://github.com/stevearc/oil.nvim/issues/254) | open | Buffer modified highlight group (P2) | -| [#263](https://github.com/stevearc/oil.nvim/issues/263) | open | Diff mode (P2) | -| [#276](https://github.com/stevearc/oil.nvim/issues/276) | open | Archives manipulation (P2) | -| [#280](https://github.com/stevearc/oil.nvim/issues/280) | open | vim-projectionist support (P2) | -| [#288](https://github.com/stevearc/oil.nvim/issues/288) | open | Oil failing to load (P2) | -| [#289](https://github.com/stevearc/oil.nvim/issues/289) | open | Show absolute path toggle (P2) | -| [#294](https://github.com/stevearc/oil.nvim/issues/294) | open | Can't handle emojis in filenames (P2) | -| [#298](https://github.com/stevearc/oil.nvim/issues/298) | open | Open float on neovim directory startup (P2) | +| Issue | Status | Notes | +| ------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [#85](https://github.com/stevearc/oil.nvim/issues/85) | open | Git status column (P2) | +| [#95](https://github.com/stevearc/oil.nvim/issues/95) | open | Undo after renaming files (P1) | +| [#117](https://github.com/stevearc/oil.nvim/issues/117) | open | Move file into new dir via slash in name (P1, related to [#708](https://github.com/stevearc/oil.nvim/pull/708)) | +| [#156](https://github.com/stevearc/oil.nvim/issues/156) | open | Paste path of files into oil buffer (P2) | +| [#200](https://github.com/stevearc/oil.nvim/issues/200) | open | Highlights not working when opening a file (P2) | +| [#207](https://github.com/stevearc/oil.nvim/issues/207) | open | Suppress "no longer available" message (P1) | +| [#210](https://github.com/stevearc/oil.nvim/issues/210) | open | FTP support (P2) | +| [#213](https://github.com/stevearc/oil.nvim/issues/213) | open | Disable preview for large files (P1) | +| [#226](https://github.com/stevearc/oil.nvim/issues/226) | open | K8s/Docker adapter (P2) | +| [#232](https://github.com/stevearc/oil.nvim/issues/232) | open | Cannot close last window (P2) | +| [#254](https://github.com/stevearc/oil.nvim/issues/254) | open | Buffer modified highlight group (P2) | +| [#263](https://github.com/stevearc/oil.nvim/issues/263) | open | Diff mode (P2) | +| [#276](https://github.com/stevearc/oil.nvim/issues/276) | open | Archives manipulation (P2) | +| [#280](https://github.com/stevearc/oil.nvim/issues/280) | open | vim-projectionist support (P2) | +| [#288](https://github.com/stevearc/oil.nvim/issues/288) | open | Oil failing to load (P2) | +| [#289](https://github.com/stevearc/oil.nvim/issues/289) | open | Show absolute path toggle (P2) | +| [#294](https://github.com/stevearc/oil.nvim/issues/294) | open | Can't handle emojis in filenames (P2) | +| [#298](https://github.com/stevearc/oil.nvim/issues/298) | open | Open float on neovim directory startup (P2) | | [#302](https://github.com/stevearc/oil.nvim/issues/302) | fixed | `buflisted=true` after jumplist nav — [#71](https://github.com/barrettruth/canola.nvim/pull/71) ([`a078bcf`](https://github.com/barrettruth/canola.nvim/commit/a078bcf)) | -| [#303](https://github.com/stevearc/oil.nvim/issues/303) | open | Preview in float window mode (P2) | -| [#325](https://github.com/stevearc/oil.nvim/issues/325) | open | oil-ssh error from command line (P0) | -| [#330](https://github.com/stevearc/oil.nvim/issues/330) | open | File opens in floating modal | -| [#332](https://github.com/stevearc/oil.nvim/issues/332) | open | Buffer not fixed to floating window (P2) | -| [#335](https://github.com/stevearc/oil.nvim/issues/335) | open | Disable editing outside root dir | -| [#349](https://github.com/stevearc/oil.nvim/issues/349) | open | Parent directory as column/vsplit (P2) | -| [#351](https://github.com/stevearc/oil.nvim/issues/351) | open | Paste deleted file from register | -| [#359](https://github.com/stevearc/oil.nvim/issues/359) | open | Parse error on filenames differing by space (P1) | -| [#360](https://github.com/stevearc/oil.nvim/issues/360) | open | Pick window to open file into | -| [#362](https://github.com/stevearc/oil.nvim/issues/362) | open | "Could not find oil adapter for scheme" error | -| [#363](https://github.com/stevearc/oil.nvim/issues/363) | open | `prompt_save_on_select_new_entry` uses wrong prompt | -| [#371](https://github.com/stevearc/oil.nvim/issues/371) | open | Constrain cursor in insert mode | -| [#373](https://github.com/stevearc/oil.nvim/issues/373) | open | Dir from quickfix with bqf/trouble broken (P1) | -| [#375](https://github.com/stevearc/oil.nvim/issues/375) | open | Highlights for file types and permissions (P2) | -| [#380](https://github.com/stevearc/oil.nvim/issues/380) | open | Show file in oil when editing hidden file | -| [#382](https://github.com/stevearc/oil.nvim/issues/382) | open | Relative path in window title (P2) | -| [#392](https://github.com/stevearc/oil.nvim/issues/392) | open | Option to skip delete prompt | -| [#393](https://github.com/stevearc/oil.nvim/issues/393) | open | Auto-save new buffer on entry | -| [#396](https://github.com/stevearc/oil.nvim/issues/396) | open | Customize preview content (P2) | -| [#399](https://github.com/stevearc/oil.nvim/issues/399) | open | Open file without closing Oil (P1) | -| [#404](https://github.com/stevearc/oil.nvim/issues/404) | not actionable | Restricted UNC paths — Windows-only (P2) | -| [#416](https://github.com/stevearc/oil.nvim/issues/416) | open | Cannot remap key to open split | -| [#431](https://github.com/stevearc/oil.nvim/issues/431) | open | More SSH adapter documentation | -| [#435](https://github.com/stevearc/oil.nvim/issues/435) | open | Error previewing with semantic tokens LSP | -| [#436](https://github.com/stevearc/oil.nvim/issues/436) | open | Owner and group columns (P2) | -| [#444](https://github.com/stevearc/oil.nvim/issues/444) | open | Opening behaviour customization | -| [#446](https://github.com/stevearc/oil.nvim/issues/446) | resolved | Executable highlighting — PR [#698](https://github.com/stevearc/oil.nvim/pull/698) | -| [#449](https://github.com/stevearc/oil.nvim/issues/449) | open | Renaming TypeScript files stopped working | -| [#450](https://github.com/stevearc/oil.nvim/issues/450) | open | Highlight opened file in directory listing | -| [#457](https://github.com/stevearc/oil.nvim/issues/457) | open | Custom column API | -| [#466](https://github.com/stevearc/oil.nvim/issues/466) | open | Select into window on right | -| [#473](https://github.com/stevearc/oil.nvim/issues/473) | open | Show all hidden files if dir only has hidden | -| [#479](https://github.com/stevearc/oil.nvim/issues/479) | open | Harpoon integration recipe | -| [#483](https://github.com/stevearc/oil.nvim/issues/483) | not actionable | Spell downloads depend on netrw — fixed in [neovim#34940](https://github.com/neovim/neovim/pull/34940) | -| [#486](https://github.com/stevearc/oil.nvim/issues/486) | open | All directory sizes show 4.1k | -| [#492](https://github.com/stevearc/oil.nvim/issues/492) | not actionable | j/k remapping question — answered in comments | -| [#507](https://github.com/stevearc/oil.nvim/issues/507) | open | lacasitos.nvim conflict (P1) | -| [#521](https://github.com/stevearc/oil.nvim/issues/521) | open | oil-ssh connection issues | -| [#525](https://github.com/stevearc/oil.nvim/issues/525) | open | SSH adapter documentation (P2) | -| [#531](https://github.com/stevearc/oil.nvim/issues/531) | not actionable | Windows — incomplete drive letters (P1) | -| [#533](https://github.com/stevearc/oil.nvim/issues/533) | not actionable | `constrain_cursor` — needs repro | -| [#570](https://github.com/stevearc/oil.nvim/issues/570) | open | Improve c0/d0 for renaming | -| [#571](https://github.com/stevearc/oil.nvim/issues/571) | open | Callback before `highlight_filename` (P2) | -| [#578](https://github.com/stevearc/oil.nvim/issues/578) | resolved | Hidden file dimming recipe — [`38db6cf`](https://github.com/barrettruth/canola.nvim/commit/38db6cf) | -| [#587](https://github.com/stevearc/oil.nvim/issues/587) | not actionable | Alt+h keymap — user config issue | -| [#599](https://github.com/stevearc/oil.nvim/issues/599) | open | user:group display and manipulation (P2) | -| [#607](https://github.com/stevearc/oil.nvim/issues/607) | open | Per-host SCP args (P2) | -| [#609](https://github.com/stevearc/oil.nvim/issues/609) | open | Cursor placement via Snacks picker | -| [#612](https://github.com/stevearc/oil.nvim/issues/612) | open | Delete buffers on file delete (P2) | -| [#615](https://github.com/stevearc/oil.nvim/issues/615) | open | Cursor at name column on o/O (P2) | -| [#617](https://github.com/stevearc/oil.nvim/issues/617) | open | Filetype by actual filetype (P2) | -| [#621](https://github.com/stevearc/oil.nvim/issues/621) | open | Toggle function for regular windows (P2) | -| [#623](https://github.com/stevearc/oil.nvim/issues/623) | not actionable | bufferline.nvim interaction — cross-plugin | -| [#624](https://github.com/stevearc/oil.nvim/issues/624) | not actionable | Mutation race — no reliable repro | -| [#625](https://github.com/stevearc/oil.nvim/issues/625) | not actionable | E19 mark invalid line — intractable without neovim API changes | -| [#632](https://github.com/stevearc/oil.nvim/issues/632) | fixed | Preview + move = copy — [#12](https://github.com/barrettruth/canola.nvim/pull/12) ([`fe16993`](https://github.com/barrettruth/canola.nvim/commit/fe16993)) | -| [#636](https://github.com/stevearc/oil.nvim/issues/636) | open | Telescope picker opens in active buffer | -| [#637](https://github.com/stevearc/oil.nvim/issues/637) | open | Inconsistent symlink resolution | -| [#641](https://github.com/stevearc/oil.nvim/issues/641) | open | Flicker on `actions.parent` | -| [#642](https://github.com/stevearc/oil.nvim/issues/642) | fixed | W10 warning under `nvim -R` — [`ca834cf`](https://github.com/barrettruth/canola.nvim/commit/ca834cf) | -| [#645](https://github.com/stevearc/oil.nvim/issues/645) | resolved | `close_float` action — [`f6bcdda`](https://github.com/barrettruth/canola.nvim/commit/f6bcdda) | -| [#646](https://github.com/stevearc/oil.nvim/issues/646) | open | `get_current_dir` nil on SSH | -| [#650](https://github.com/stevearc/oil.nvim/issues/650) | open | Emit LSP `workspace.fileOperations` events | -| [#655](https://github.com/stevearc/oil.nvim/issues/655) | open | File statistics as virtual text | -| [#659](https://github.com/stevearc/oil.nvim/issues/659) | open | Mark and diff files in buffer | -| [#664](https://github.com/stevearc/oil.nvim/issues/664) | not actionable | Session reload extra buffer — no repro | -| [#665](https://github.com/stevearc/oil.nvim/issues/665) | open | Hot load preview fast-scratch buffers | -| [#668](https://github.com/stevearc/oil.nvim/issues/668) | open | Custom yes/no confirmation | -| [#670](https://github.com/stevearc/oil.nvim/issues/670) | fixed | Multi-directory cmdline — [#11](https://github.com/barrettruth/canola.nvim/pull/11) ([`70861e5`](https://github.com/barrettruth/canola.nvim/commit/70861e5)) | -| [#671](https://github.com/stevearc/oil.nvim/issues/671) | open | Yanking between nvim instances | -| [#673](https://github.com/stevearc/oil.nvim/issues/673) | fixed | Symlink newlines crash — [`9110a1a`](https://github.com/barrettruth/canola.nvim/commit/9110a1a) | -| [#675](https://github.com/stevearc/oil.nvim/issues/675) | open | Move file into folder by renaming (related to [#708](https://github.com/stevearc/oil.nvim/pull/708)) | -| [#676](https://github.com/stevearc/oil.nvim/issues/676) | not actionable | Windows — path conversion | -| [#678](https://github.com/stevearc/oil.nvim/issues/678) | tracking | `buftype='acwrite'` causes `mksession` to skip oil windows | -| [#679](https://github.com/stevearc/oil.nvim/issues/679) | resolved | Executable file sign — PR [#698](https://github.com/stevearc/oil.nvim/pull/698) | -| [#682](https://github.com/stevearc/oil.nvim/issues/682) | open | `get_current_dir()` nil in non-telescope context | -| [#683](https://github.com/stevearc/oil.nvim/issues/683) | open | Path not shown in floating mode | -| [#684](https://github.com/stevearc/oil.nvim/issues/684) | open | User and group columns | -| [#685](https://github.com/stevearc/oil.nvim/issues/685) | open | Plain directory paths in buffer names | -| [#690](https://github.com/stevearc/oil.nvim/issues/690) | resolved | `OilFileIcon` highlight group — [`ce64ae1`](https://github.com/barrettruth/canola.nvim/commit/ce64ae1) | -| [#692](https://github.com/stevearc/oil.nvim/issues/692) | resolved | Keymap normalization — PR [#725](https://github.com/stevearc/oil.nvim/pull/725) | -| [#699](https://github.com/stevearc/oil.nvim/issues/699) | open | `select` blocks UI with slow FileType autocmd | -| [#707](https://github.com/stevearc/oil.nvim/issues/707) | open | Move file/dir into new dir by renaming (related to [#708](https://github.com/stevearc/oil.nvim/pull/708)) | -| [#710](https://github.com/stevearc/oil.nvim/issues/710) | fixed | buftype empty on BufEnter — [#10](https://github.com/barrettruth/canola.nvim/pull/10) ([`01b860e`](https://github.com/barrettruth/canola.nvim/commit/01b860e)) | -| [#714](https://github.com/stevearc/oil.nvim/issues/714) | not actionable | Support question — answered | -| [#719](https://github.com/stevearc/oil.nvim/issues/719) | not actionable | Neovim crash on node_modules — libuv/neovim bug | -| [#726](https://github.com/stevearc/oil.nvim/issues/726) | not actionable | Meta discussion/roadmap | -| [#736](https://github.com/stevearc/oil.nvim/issues/736) | open | feature request: make icons virtual text | +| [#303](https://github.com/stevearc/oil.nvim/issues/303) | open | Preview in float window mode (P2) | +| [#325](https://github.com/stevearc/oil.nvim/issues/325) | open | oil-ssh error from command line (P0) | +| [#330](https://github.com/stevearc/oil.nvim/issues/330) | open | File opens in floating modal | +| [#332](https://github.com/stevearc/oil.nvim/issues/332) | open | Buffer not fixed to floating window (P2) | +| [#335](https://github.com/stevearc/oil.nvim/issues/335) | open | Disable editing outside root dir | +| [#349](https://github.com/stevearc/oil.nvim/issues/349) | open | Parent directory as column/vsplit (P2) | +| [#351](https://github.com/stevearc/oil.nvim/issues/351) | open | Paste deleted file from register | +| [#359](https://github.com/stevearc/oil.nvim/issues/359) | open | Parse error on filenames differing by space (P1) | +| [#360](https://github.com/stevearc/oil.nvim/issues/360) | open | Pick window to open file into | +| [#362](https://github.com/stevearc/oil.nvim/issues/362) | open | "Could not find oil adapter for scheme" error | +| [#363](https://github.com/stevearc/oil.nvim/issues/363) | open | `prompt_save_on_select_new_entry` uses wrong prompt | +| [#371](https://github.com/stevearc/oil.nvim/issues/371) | open | Constrain cursor in insert mode | +| [#373](https://github.com/stevearc/oil.nvim/issues/373) | open | Dir from quickfix with bqf/trouble broken (P1) | +| [#375](https://github.com/stevearc/oil.nvim/issues/375) | open | Highlights for file types and permissions (P2) | +| [#380](https://github.com/stevearc/oil.nvim/issues/380) | open | Show file in oil when editing hidden file | +| [#382](https://github.com/stevearc/oil.nvim/issues/382) | open | Relative path in window title (P2) | +| [#392](https://github.com/stevearc/oil.nvim/issues/392) | open | Option to skip delete prompt | +| [#393](https://github.com/stevearc/oil.nvim/issues/393) | open | Auto-save new buffer on entry | +| [#396](https://github.com/stevearc/oil.nvim/issues/396) | open | Customize preview content (P2) | +| [#399](https://github.com/stevearc/oil.nvim/issues/399) | open | Open file without closing Oil (P1) | +| [#404](https://github.com/stevearc/oil.nvim/issues/404) | not actionable | Restricted UNC paths — Windows-only (P2) | +| [#416](https://github.com/stevearc/oil.nvim/issues/416) | open | Cannot remap key to open split | +| [#431](https://github.com/stevearc/oil.nvim/issues/431) | open | More SSH adapter documentation | +| [#435](https://github.com/stevearc/oil.nvim/issues/435) | open | Error previewing with semantic tokens LSP | +| [#436](https://github.com/stevearc/oil.nvim/issues/436) | open | Owner and group columns (P2) | +| [#444](https://github.com/stevearc/oil.nvim/issues/444) | open | Opening behaviour customization | +| [#446](https://github.com/stevearc/oil.nvim/issues/446) | resolved | Executable highlighting — PR [#698](https://github.com/stevearc/oil.nvim/pull/698) | +| [#449](https://github.com/stevearc/oil.nvim/issues/449) | open | Renaming TypeScript files stopped working | +| [#450](https://github.com/stevearc/oil.nvim/issues/450) | open | Highlight opened file in directory listing | +| [#457](https://github.com/stevearc/oil.nvim/issues/457) | open | Custom column API | +| [#466](https://github.com/stevearc/oil.nvim/issues/466) | open | Select into window on right | +| [#473](https://github.com/stevearc/oil.nvim/issues/473) | open | Show all hidden files if dir only has hidden | +| [#479](https://github.com/stevearc/oil.nvim/issues/479) | open | Harpoon integration recipe | +| [#483](https://github.com/stevearc/oil.nvim/issues/483) | not actionable | Spell downloads depend on netrw — fixed in [neovim#34940](https://github.com/neovim/neovim/pull/34940) | +| [#486](https://github.com/stevearc/oil.nvim/issues/486) | open | All directory sizes show 4.1k | +| [#492](https://github.com/stevearc/oil.nvim/issues/492) | not actionable | j/k remapping question — answered in comments | +| [#507](https://github.com/stevearc/oil.nvim/issues/507) | open | lacasitos.nvim conflict (P1) | +| [#521](https://github.com/stevearc/oil.nvim/issues/521) | open | oil-ssh connection issues | +| [#525](https://github.com/stevearc/oil.nvim/issues/525) | open | SSH adapter documentation (P2) | +| [#531](https://github.com/stevearc/oil.nvim/issues/531) | not actionable | Windows — incomplete drive letters (P1) | +| [#533](https://github.com/stevearc/oil.nvim/issues/533) | not actionable | `constrain_cursor` — needs repro | +| [#570](https://github.com/stevearc/oil.nvim/issues/570) | open | Improve c0/d0 for renaming | +| [#571](https://github.com/stevearc/oil.nvim/issues/571) | open | Callback before `highlight_filename` (P2) | +| [#578](https://github.com/stevearc/oil.nvim/issues/578) | resolved | Hidden file dimming recipe — [`38db6cf`](https://github.com/barrettruth/canola.nvim/commit/38db6cf) | +| [#587](https://github.com/stevearc/oil.nvim/issues/587) | not actionable | Alt+h keymap — user config issue | +| [#599](https://github.com/stevearc/oil.nvim/issues/599) | open | user:group display and manipulation (P2) | +| [#607](https://github.com/stevearc/oil.nvim/issues/607) | open | Per-host SCP args (P2) | +| [#609](https://github.com/stevearc/oil.nvim/issues/609) | open | Cursor placement via Snacks picker | +| [#612](https://github.com/stevearc/oil.nvim/issues/612) | fixed | Delete buffers on file delete — `cleanup_buffers_on_delete` option | +| [#615](https://github.com/stevearc/oil.nvim/issues/615) | open | Cursor at name column on o/O (P2) | +| [#617](https://github.com/stevearc/oil.nvim/issues/617) | open | Filetype by actual filetype (P2) | +| [#621](https://github.com/stevearc/oil.nvim/issues/621) | open | Toggle function for regular windows (P2) | +| [#623](https://github.com/stevearc/oil.nvim/issues/623) | not actionable | bufferline.nvim interaction — cross-plugin | +| [#624](https://github.com/stevearc/oil.nvim/issues/624) | not actionable | Mutation race — no reliable repro | +| [#625](https://github.com/stevearc/oil.nvim/issues/625) | not actionable | E19 mark invalid line — intractable without neovim API changes | +| [#632](https://github.com/stevearc/oil.nvim/issues/632) | fixed | Preview + move = copy — [#12](https://github.com/barrettruth/canola.nvim/pull/12) ([`fe16993`](https://github.com/barrettruth/canola.nvim/commit/fe16993)) | +| [#636](https://github.com/stevearc/oil.nvim/issues/636) | open | Telescope picker opens in active buffer | +| [#637](https://github.com/stevearc/oil.nvim/issues/637) | open | Inconsistent symlink resolution | +| [#641](https://github.com/stevearc/oil.nvim/issues/641) | open | Flicker on `actions.parent` | +| [#642](https://github.com/stevearc/oil.nvim/issues/642) | fixed | W10 warning under `nvim -R` — [`ca834cf`](https://github.com/barrettruth/canola.nvim/commit/ca834cf) | +| [#645](https://github.com/stevearc/oil.nvim/issues/645) | resolved | `close_float` action — [`f6bcdda`](https://github.com/barrettruth/canola.nvim/commit/f6bcdda) | +| [#646](https://github.com/stevearc/oil.nvim/issues/646) | open | `get_current_dir` nil on SSH | +| [#650](https://github.com/stevearc/oil.nvim/issues/650) | open | Emit LSP `workspace.fileOperations` events | +| [#655](https://github.com/stevearc/oil.nvim/issues/655) | open | File statistics as virtual text | +| [#659](https://github.com/stevearc/oil.nvim/issues/659) | open | Mark and diff files in buffer | +| [#664](https://github.com/stevearc/oil.nvim/issues/664) | not actionable | Session reload extra buffer — no repro | +| [#665](https://github.com/stevearc/oil.nvim/issues/665) | open | Hot load preview fast-scratch buffers | +| [#668](https://github.com/stevearc/oil.nvim/issues/668) | open | Custom yes/no confirmation | +| [#670](https://github.com/stevearc/oil.nvim/issues/670) | fixed | Multi-directory cmdline — [#11](https://github.com/barrettruth/canola.nvim/pull/11) ([`70861e5`](https://github.com/barrettruth/canola.nvim/commit/70861e5)) | +| [#671](https://github.com/stevearc/oil.nvim/issues/671) | open | Yanking between nvim instances | +| [#673](https://github.com/stevearc/oil.nvim/issues/673) | fixed | Symlink newlines crash — [`9110a1a`](https://github.com/barrettruth/canola.nvim/commit/9110a1a) | +| [#675](https://github.com/stevearc/oil.nvim/issues/675) | open | Move file into folder by renaming (related to [#708](https://github.com/stevearc/oil.nvim/pull/708)) | +| [#676](https://github.com/stevearc/oil.nvim/issues/676) | not actionable | Windows — path conversion | +| [#678](https://github.com/stevearc/oil.nvim/issues/678) | tracking | `buftype='acwrite'` causes `mksession` to skip oil windows | +| [#679](https://github.com/stevearc/oil.nvim/issues/679) | resolved | Executable file sign — PR [#698](https://github.com/stevearc/oil.nvim/pull/698) | +| [#682](https://github.com/stevearc/oil.nvim/issues/682) | open | `get_current_dir()` nil in non-telescope context | +| [#683](https://github.com/stevearc/oil.nvim/issues/683) | open | Path not shown in floating mode | +| [#684](https://github.com/stevearc/oil.nvim/issues/684) | open | User and group columns | +| [#685](https://github.com/stevearc/oil.nvim/issues/685) | open | Plain directory paths in buffer names | +| [#690](https://github.com/stevearc/oil.nvim/issues/690) | resolved | `OilFileIcon` highlight group — [`ce64ae1`](https://github.com/barrettruth/canola.nvim/commit/ce64ae1) | +| [#692](https://github.com/stevearc/oil.nvim/issues/692) | resolved | Keymap normalization — PR [#725](https://github.com/stevearc/oil.nvim/pull/725) | +| [#699](https://github.com/stevearc/oil.nvim/issues/699) | open | `select` blocks UI with slow FileType autocmd | +| [#707](https://github.com/stevearc/oil.nvim/issues/707) | open | Move file/dir into new dir by renaming (related to [#708](https://github.com/stevearc/oil.nvim/pull/708)) | +| [#710](https://github.com/stevearc/oil.nvim/issues/710) | fixed | buftype empty on BufEnter — [#10](https://github.com/barrettruth/canola.nvim/pull/10) ([`01b860e`](https://github.com/barrettruth/canola.nvim/commit/01b860e)) | +| [#714](https://github.com/stevearc/oil.nvim/issues/714) | not actionable | Support question — answered | +| [#719](https://github.com/stevearc/oil.nvim/issues/719) | not actionable | Neovim crash on node_modules — libuv/neovim bug | +| [#726](https://github.com/stevearc/oil.nvim/issues/726) | not actionable | Meta discussion/roadmap | +| [#736](https://github.com/stevearc/oil.nvim/issues/736) | open | feature request: make icons virtual text | diff --git a/lua/canola/config.lua b/lua/canola/config.lua index 607f4c0..3790661 100644 --- a/lua/canola/config.lua +++ b/lua/canola/config.lua @@ -28,6 +28,8 @@ local default_config = { }, -- Send deleted files to the trash instead of permanently deleting them (:help canola-trash) delete_to_trash = false, + -- Wipe open buffers for files deleted via canola (:help canola.cleanup_buffers_on_delete) + cleanup_buffers_on_delete = false, -- Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits) skip_confirm_for_simple_edits = false, -- Selecting a new/moved/renamed file or directory will prompt you to save changes first @@ -232,6 +234,7 @@ default_config.view_options.highlight_filename = nil ---@field buf_options table ---@field win_options table ---@field delete_to_trash boolean +---@field cleanup_buffers_on_delete boolean ---@field skip_confirm_for_simple_edits boolean ---@field prompt_save_on_select_new_entry boolean ---@field cleanup_delay_ms integer @@ -263,6 +266,7 @@ local M = {} ---@field buf_options? table Buffer-local options to use for canola buffers ---@field win_options? table Window-local options to use for canola buffers ---@field delete_to_trash? boolean Send deleted files to the trash instead of permanently deleting them (:help canola-trash). +---@field cleanup_buffers_on_delete? boolean Wipe open buffers for files deleted via canola (:help canola.cleanup_buffers_on_delete). ---@field skip_confirm_for_simple_edits? boolean Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits). ---@field prompt_save_on_select_new_entry? boolean Selecting a new/moved/renamed file or directory will prompt you to save changes first (:help prompt_save_on_select_new_entry). ---@field cleanup_delay_ms? integer Canola will automatically delete hidden buffers after this delay. You can set the delay to false to disable cleanup entirely. Note that the cleanup process only starts when none of the canola buffers are currently displayed. diff --git a/lua/canola/mutator/init.lua b/lua/canola/mutator/init.lua index 34cf2b1..626ec70 100644 --- a/lua/canola/mutator/init.lua +++ b/lua/canola/mutator/init.lua @@ -420,6 +420,21 @@ M.process_actions = function(actions, cb) finished = true progress:close() progress = nil + if config.cleanup_buffers_on_delete and not err then + for _, action in ipairs(actions) do + if action.type == 'delete' then + local scheme, path = util.parse_url(action.url) + if config.adapters[scheme] == 'files' then + assert(path) + local os_path = fs.posix_to_os_path(path) + local bufnr = vim.fn.bufnr(os_path) + if bufnr ~= -1 then + vim.api.nvim_buf_delete(bufnr, { force = true }) + end + end + end + end + end vim.api.nvim_exec_autocmds( 'User', { pattern = 'CanolaActionsPost', modeline = false, data = { err = err, actions = actions } } diff --git a/spec/files_spec.lua b/spec/files_spec.lua index 7c430f3..0282c0b 100644 --- a/spec/files_spec.lua +++ b/spec/files_spec.lua @@ -163,4 +163,47 @@ describe('files adapter', function() assert.equals(vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb', vim.api.nvim_buf_get_name(0)) assert.equals(tmpdir.path .. '/file.rb', vim.fn.bufname()) end) + + describe('cleanup_buffers_on_delete', function() + local cache = require('canola.cache') + local config = require('canola.config') + local mutator = require('canola.mutator') + + before_each(function() + config.cleanup_buffers_on_delete = true + end) + + after_each(function() + config.cleanup_buffers_on_delete = false + end) + + it('wipes the buffer for a deleted file', function() + tmpdir:create({ 'a.txt' }) + local dirurl = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') + local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt' + cache.create_and_store_entry(dirurl, 'a.txt', 'file') + vim.cmd.edit({ args = { filepath } }) + local bufnr = vim.api.nvim_get_current_buf() + local url = 'canola://' .. filepath + test_util.await(mutator.process_actions, 2, { + { type = 'delete', url = url, entry_type = 'file' }, + }) + assert.is_false(vim.api.nvim_buf_is_valid(bufnr)) + end) + + it('does not wipe the buffer when disabled', function() + config.cleanup_buffers_on_delete = false + tmpdir:create({ 'b.txt' }) + local dirurl = 'canola://' .. vim.fn.fnamemodify(tmpdir.path, ':p') + local filepath = vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt' + cache.create_and_store_entry(dirurl, 'b.txt', 'file') + vim.cmd.edit({ args = { filepath } }) + local bufnr = vim.api.nvim_get_current_buf() + local url = 'canola://' .. filepath + test_util.await(mutator.process_actions, 2, { + { type = 'delete', url = url, entry_type = 'file' }, + }) + assert.is_true(vim.api.nvim_buf_is_valid(bufnr)) + end) + end) end)