Compare commits
No commits in common. "2d6f6e825f07e183eb90f2f2695b8aadd860c09e" and "69d85b8de1e178b6c903d9aefc3767f43ce2cb43" have entirely different histories.
2d6f6e825f
...
69d85b8de1
5 changed files with 108 additions and 177 deletions
|
|
@ -311,12 +311,6 @@ 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*
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ Bugs fixed in this fork that remain open upstream.
|
|||
| [#642](https://github.com/stevearc/oil.nvim/issues/642) | W10 warning under `nvim -R` | [`ca834cf`](https://github.com/barrettruth/canola.nvim/commit/ca834cf) |
|
||||
| [#670](https://github.com/stevearc/oil.nvim/issues/670) | Multi-directory cmdline args ignored | [#11](https://github.com/barrettruth/canola.nvim/pull/11) ([`70861e5`](https://github.com/barrettruth/canola.nvim/commit/70861e5)) |
|
||||
| [#673](https://github.com/stevearc/oil.nvim/issues/673) | Symlink newlines crash | [`9110a1a`](https://github.com/barrettruth/canola.nvim/commit/9110a1a) |
|
||||
| [#612](https://github.com/stevearc/oil.nvim/issues/612) | Delete buffers on file delete | [#73](https://github.com/barrettruth/canola.nvim/pull/73) ([`047338a`](https://github.com/barrettruth/canola.nvim/commit/047338a)) |
|
||||
| [#710](https://github.com/stevearc/oil.nvim/issues/710) | buftype empty on BufEnter | [#10](https://github.com/barrettruth/canola.nvim/pull/10) ([`01b860e`](https://github.com/barrettruth/canola.nvim/commit/01b860e)) |
|
||||
|
||||
## Open upstream PRs
|
||||
|
|
@ -57,7 +56,7 @@ 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)) |
|
||||
|
|
@ -125,7 +124,7 @@ addressed, `open` = not yet triaged.
|
|||
| [#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 |
|
||||
| [#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) |
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ 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
|
||||
|
|
@ -234,7 +232,6 @@ default_config.view_options.highlight_filename = nil
|
|||
---@field buf_options table<string, any>
|
||||
---@field win_options table<string, any>
|
||||
---@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
|
||||
|
|
@ -266,7 +263,6 @@ local M = {}
|
|||
---@field buf_options? table<string, any> Buffer-local options to use for canola buffers
|
||||
---@field win_options? table<string, any> 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.
|
||||
|
|
|
|||
|
|
@ -420,21 +420,6 @@ 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 } }
|
||||
|
|
|
|||
|
|
@ -163,47 +163,4 @@ 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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue