From c377c8be6185f0773163c915d3caf0862bc26f53 Mon Sep 17 00:00:00 2001 From: Tommy Allen Date: Mon, 17 Oct 2016 17:16:56 -0400 Subject: vim-patch:8.0.0041 Problem: When using Insert mode completion but not actually inserting anything an undo item is still created. (Tommy Allen) Solution: Do not call stop_arrow() when not inserting anything. --- test/functional/viml/completion_spec.lua | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'test') diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 0897c2d836..da3400fb27 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -317,6 +317,62 @@ describe('completion', function() end) end) + describe('completeopt+=noinsert does not add blank undo items', function() + before_each(function() + source([[ + function! TestComplete() abort + call complete(1, ['foo', 'bar']) + return '' + endfunction + ]]) + execute('set completeopt+=noselect,noinsert') + execute('inoremap =TestComplete()') + end) + + local tests = { + [', , '] = {'', ''}, + [', , '] = {'', ''}, + } + + for name, seq in pairs(tests) do + it('using ' .. name, function() + feed('iaaa') + feed('A' .. seq[1] .. '') + feed('AA') + feed('Abbb') + feed('A' .. seq[2] .. '') + feed('AA') + feed('Accc') + feed('A' .. seq[1] .. '') + feed('AA') + + local expected = { + {'foo', 'bar', 'foo'}, + {'foo', 'bar', 'ccc'}, + {'foo', 'bar'}, + {'foo', 'bbb'}, + {'foo'}, + {'aaa'}, + {''}, + } + + for i = 1, #expected do + if i > 1 then + feed('u') + end + eq(expected[i], eval('getline(1, "$")')) + end + + for i = #expected, 1, -1 do + if i < #expected then + feed('') + end + eq(expected[i], eval('getline(1, "$")')) + end + end) + end + end) + describe("refresh:always", function() before_each(function() source([[ -- cgit