fix: is_end_line function

This commit is contained in:
windwp 2021-07-24 07:09:46 +07:00
parent 5a86b4f83c
commit e3e105b11a
2 changed files with 14 additions and 4 deletions

View File

@ -191,8 +191,9 @@ end
cond.is_end_line = function()
return function(opts)
log.debug('is_end_line')
-- if the next char is blank
if opts.next_char ~= "" and opts.next_char:match("%s+") == nil then
local end_text = opts.line:sub(opts.col + 1)
-- end text is blank
if end_text ~= "" and end_text:match("^%s+$") == nil then
return false
end
end

View File

@ -17,8 +17,17 @@ local data = {
filetype = "lua",
linenr = 5,
key = [[<cr>]],
before = [[function a()| ]],
after = [[ end ]]
before = [[function a()| ]],
after = [[ end ]]
},
{
name = "lua function add endwise" ,
filepath = './tests/endwise/init.lua',
filetype = "lua",
linenr = 5,
key = [[<cr>]],
before = [[function a()|x ab ]],
after = [[]]
},
{
name = "add if endwise" ,