fix(action.delete_buffer): improve behavior with splits (#3194)

Previously, when having window splits, with deleting a buffer involving
deleting a window, getting the jumplist for said deleted window would
result in an invalid jumplist. Trying to iterate over this invalid
jumplist would error out.

When there are split, there's no need to find a valid buffer to switch
the current window to (as the window is deleted). Instead, what's needed
is the updating of telescope's `picker.original_win_id` state. This is
important for when chaining buffer deletes (ie. closing many splits).

Also improve behavior when the "current" buffer is the only valid buffer
-> it will now open an empty buffer (same as when doing `:bdelete`).
This commit is contained in:
James Trew
2024-07-01 15:06:50 -04:00
committed by GitHub
parent 7bd2f9b72f
commit bfcc7d5c6f
2 changed files with 21 additions and 6 deletions

View File

@@ -537,6 +537,7 @@ function Picker:find()
self.original_bufnr = a.nvim_get_current_buf()
self.original_win_id = a.nvim_get_current_win()
self.original_tabpage = a.nvim_get_current_tabpage()
_, self.original_cword = pcall(vim.fn.expand, "<cword>")
_, self.original_cWORD = pcall(vim.fn.expand, "<cWORD>")
_, self.original_cfile = pcall(vim.fn.expand, "<cfile>")