-
Notifications
You must be signed in to change notification settings - Fork 169
Open
Description
Description
Neovim crashes (exit code 139) when accepting a new file diff via :w with render-markdown.nvim installed. Existing file diffs work fine — this only happens with new files.
Minimal Reproduction
-- Save as repro.lua, run: nvim -u repro.lua
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
local lazypath = vim.fn.stdpath("data") .. "/lazy-repro/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--branch=stable",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = {},
},
{
"coder/claudecode.nvim",
opts = {
terminal = { split_side = "left", split_width_percentage = 0.5 },
diff_opts = { open_in_new_tab = true, hide_terminal_in_new_tab = true },
},
keys = { { "<C-,>", "<cmd>ClaudeCode<cr>", desc = "Toggle Claude" } },
},
{
"MeanderingProgrammer/render-markdown.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
opts = {},
},
}, { root = vim.fn.stdpath("data") .. "/lazy-repro" })Steps to Reproduce
- Start Neovim with the config above
- Open Claude terminal (
<C-,>) - Ask Claude to create a new
.mdfile - When the diff appears, make sure cursor is in the proposed (right) buffer
- Type
:wto accept - Neovim crashes with exit code 139
What I've found so far
- Only happens with new files, not existing file diffs
- Removing
render-markdown.nvimprevents the crash - I added file-based logging (breadcrumbs) throughout the code. All the Lua code in
_resolve_diff_as_saved()and theBufWriteCmdcallback completes successfully — the crash seems to happen after the callback returns control back to Neovim - Adding
pcall(vim.cmd, "diffoff")at the end of theBufWriteCmdcallback (after_resolve_diff_as_savedbut beforereturn true) prevents the crash. I'm not 100% sure why, but it seems like turning off diff mode before Neovim does its post-write redraw avoids whatever triggers the crash - I wasn't able to reproduce the crash outside of claudecode's MCP flow (i.e., manually setting up the same buffer/diff state doesn't crash), so there may be a timing or event-loop component I don't fully understand
Suggested fix
This one-liner in register_diff_autocmds prevents the crash, and all existing tests pass with it:
callback = function()
M._resolve_diff_as_saved(tab_name, new_buffer)
pcall(vim.cmd, "diffoff") -- prevents crash with render-markdown.nvim
return true
end,Environment
- Neovim: 0.11.0
- OS: macOS (Darwin 24.6.0)
- render-markdown.nvim: latest
- claudecode.nvim: latest
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels