Skip to content

Invalid undo after O newline insert before oneline #5524

@A4-Tacks

Description

@A4-Tacks

Result from CocInfo

## versions

vim version: VIM - Vi IMproved 9.1 9011908
node version: v23.9.0
coc.nvim version: 0.0.82-9d00dc1 2025-12-15 17:22:19 +0800
coc.nvim directory: /home/lrne/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2026-01-11T16:18:20.362 INFO (pid:27112) [plugin] - coc.nvim initialized with node: v23.9.0 after 443
2026-01-11T16:18:25.287 INFO (pid:27112) [attach] - receive notification: showInfo []

Describe the bug

Open a single line file, insert and undo a new line before the first line, and the file becomes empty

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't
reproduce it

  • Create file mini.vim with:

    set nocompatible
    set runtimepath^=~/.vim/plugged/coc.nvim
    filetype plugin indent on
    syntax on
  • Run echo a b c > foo.txt

  • Start (neo)vim with command: vim -Nu mini.vim foo.txt

  • Operate vim.

    1. On line 1, input O
    2. Insert foo
    3. Click <esc> u

    Expect: a b c

    Actual: empty file

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions