fix(commands): handle :e on diffs:// buffers via BufReadCmd
Problem: running :e on a :Gdiff buffer cleared all content because diffs:// buffers had no BufReadCmd handler. Neovim tried to read the buffer name as a file path, found nothing on disk, and emptied the buffer. This affected all three buffer creation paths (gdiff, gdiff_file, gdiff_section). Solution: register a BufReadCmd autocmd for diffs://* that parses the URL and regenerates diff content from git. Change buffer options from nofile/wipe to nowrite/delete (matching fugitive's approach) so buffer-local autocmds and variables survive across unload/reload cycles. Store old filepath as buffer variable for rename support.
This commit is contained in:
parent
b6f1c5b749
commit
f948982848
3 changed files with 490 additions and 6 deletions
|
|
@ -23,6 +23,13 @@ vim.api.nvim_create_autocmd('FileType', {
|
|||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufReadCmd', {
|
||||
pattern = 'diffs://*',
|
||||
callback = function(args)
|
||||
require('diffs.commands').read_buffer(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('OptionSet', {
|
||||
pattern = 'diff',
|
||||
callback = function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue