feat: add auto_save_on_select_new_entry config option (#84)
Problem: users who want hands-off behaviour had no way to skip the `prompt_save_on_select_new_entry` confirmation dialog — enabling the prompt meant always being asked, with no silent auto-save path. Solution: add `auto_save_on_select_new_entry` (default `false`) which, when true, calls `M.save()` and proceeds immediately instead of showing the confirm dialog. Includes type annotations, vimdoc, and upstream tracker update for stevearc/oil.nvim#393.
This commit is contained in:
parent
082573d779
commit
a9a06b8f3b
4 changed files with 14 additions and 1 deletions
|
|
@ -316,6 +316,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.
|
||||
|
||||
auto_save_on_select_new_entry *canola.auto_save_on_select_new_entry*
|
||||
type: `boolean` default: `false`
|
||||
When `prompt_save_on_select_new_entry` is true and you select a
|
||||
new/moved/renamed entry, automatically save without prompting instead of
|
||||
showing a confirmation dialog.
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Bugs fixed in this fork that remain open upstream.
|
|||
| [#380](https://github.com/stevearc/oil.nvim/issues/380) | open | Show currently-edited hidden files in listing even when `show_hidden = false`; no upstream response, nice to have |
|
||||
| [#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) | fixed | Option to skip delete prompt — fixed — `skip_confirm_for_delete` option |
|
||||
| [#393](https://github.com/stevearc/oil.nvim/issues/393) | open | Auto-save new buffer on entry; no upstream design yet, possible interaction gap with `prompt_save_on_select_new_entry` + `skip_confirm_for_simple_edits` |
|
||||
| [#393](https://github.com/stevearc/oil.nvim/issues/393) | fixed | Auto-save on select — `auto_save_on_select_new_entry` option |
|
||||
| [#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) |
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ local default_config = {
|
|||
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
|
||||
-- (:help prompt_save_on_select_new_entry)
|
||||
prompt_save_on_select_new_entry = true,
|
||||
auto_save_on_select_new_entry = false,
|
||||
-- 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
|
||||
|
|
@ -239,6 +240,7 @@ default_config.view_options.highlight_filename = nil
|
|||
---@field skip_confirm_for_simple_edits boolean
|
||||
---@field skip_confirm_for_delete boolean
|
||||
---@field prompt_save_on_select_new_entry boolean
|
||||
---@field auto_save_on_select_new_entry boolean
|
||||
---@field cleanup_delay_ms integer
|
||||
---@field lsp_file_methods canola.LspFileMethods
|
||||
---@field constrain_cursor false|"name"|"editable"
|
||||
|
|
@ -272,6 +274,7 @@ local M = {}
|
|||
---@field skip_confirm_for_simple_edits? boolean Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits).
|
||||
---@field skip_confirm_for_delete? boolean Skip the confirmation popup when all pending actions are deletes (:help canola.skip_confirm_for_delete).
|
||||
---@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 auto_save_on_select_new_entry? boolean Automatically save changes when selecting a new/moved/renamed entry, instead of prompting (:help canola.auto_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.
|
||||
---@field lsp_file_methods? canola.SetupLspFileMethods Configure LSP file operation integration.
|
||||
---@field constrain_cursor? false|"name"|"editable" Constrain the cursor to the editable parts of the canola buffer. Set to `false` to disable, or "name" to keep it on the file names.
|
||||
|
|
|
|||
|
|
@ -788,6 +788,10 @@ M.select = function(opts, callback)
|
|||
end
|
||||
end
|
||||
if any_moved and config.prompt_save_on_select_new_entry then
|
||||
if config.auto_save_on_select_new_entry then
|
||||
M.save()
|
||||
return finish()
|
||||
end
|
||||
local ok, choice = pcall(vim.fn.confirm, 'Save changes?', 'Yes\nNo', 1)
|
||||
if not ok then
|
||||
return finish()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue