Skip to content

fix: Restore the original key mappings after handling <CR> or <C-j> - #623

Open
alohaia wants to merge 2 commits into
R-nvim:mainfrom
alohaia:main
Open

alohaia wants to merge 2 commits into
R-nvim:mainfrom
alohaia:main

Conversation

@alohaia

@alohaia alohaia commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@PMassicotte

Copy link
Copy Markdown
Collaborator

Thanks for the fix! I pushed a follow-up commit on top of yours: it saves the original mappings only once per buffer (typing two pipes in a row could otherwise save our own temporary mapping). Let me know what you think.

@alohaia

alohaia commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

You are right, I didn't consider that. But setting once = true actually triggers the autocmd once for each event of { "TextChangedI", "CursorMovedI", "InsertLeave" }, using vim.api.nvim_del_autocmd maybe better:

        vim.schedule(function()
            vim.api.nvim_create_autocmd(
                { "TextChangedI", "CursorMovedI", "InsertLeave" },
                {
                    buffer = bufnr,
                    callback = function(args)
                        restore_pipe_maps(bufnr)
                        pcall(vim.api.nvim_del_autocmd, args.id)
                    end,
                }
            )
        end)

@PMassicotte

Copy link
Copy Markdown
Collaborator

Sure, can you make the change please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants