neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

undojoin_spec.lua (911B)


      1 local t = require('test.testutil')
      2 local n = require('test.functional.testnvim')()
      3 
      4 local eq = t.eq
      5 local clear = n.clear
      6 local insert = n.insert
      7 local feed = n.feed
      8 local expect = n.expect
      9 local feed_command = n.feed_command
     10 local exc_exec = n.exc_exec
     11 
     12 describe(':undojoin command', function()
     13  before_each(function()
     14    clear()
     15    insert([[
     16    Line of text 1
     17    Line of text 2]])
     18    feed_command('goto 1')
     19  end)
     20  it('joins changes in a buffer', function()
     21    feed_command('undojoin | delete')
     22    expect([[
     23    Line of text 2]])
     24    feed('u')
     25    expect([[
     26    ]])
     27  end)
     28  it('does not corrupt undolist when connected with redo', function()
     29    feed('ixx<esc>')
     30    feed_command('undojoin | redo')
     31    expect([[
     32    xxLine of text 1
     33    Line of text 2]])
     34  end)
     35  it('does not raise an error when called twice', function()
     36    local ret = exc_exec('undojoin | undojoin')
     37    eq(0, ret)
     38  end)
     39 end)