tests/bundled/lh-vim-lib/tests/lh/test-command.vim @ 9a42f3562a99
Neovim support: line buffers shouldn't contain newlines The result of `difflib.unified_diff()` may contains newlines at the end of its each line. It's suppressed in original Vim, but it's illegal in Neovim. Since there is no good way to prevent `difflib` from appending newlines to the results, `_output_preview_text()` function should sanitize it. Thanks @michamos Reference: https://github.com/neovim/neovim/blob/a5edc5f2572d6d63f7f7a32ae6ec7bcabe1472b6/src/nvim/api/buffer.c#L215 https://github.com/sjl/gundo.vim/pull/30#issuecomment-170064637
| author | Hyeon Kim <simnalamburt@gmail.com> |
|---|---|
| date | Mon, 15 Dec 2014 06:29:40 +0900 |
| parents | 2b3d5ee5c4a4 |
| children | (none) |
" $Id: test-command.vim 156 2010-05-07 00:54:36Z luc.hermitte $ " Tests for lh-vim-lib . lh#command " FindFilter(filter): Helper {{{3 function! s:FindFilter(filter) let filter = a:filter . '.vim' let result =globpath(&rtp, "compiler/BTW-".filter) . "\n" . \ globpath(&rtp, "compiler/BTW_".filter). "\n" . \ globpath(&rtp, "compiler/BTW/".filter) let result = substitute(result, '\n\n', '\n', 'g') let result = substitute(result, '^\n', '', 'g') return result endfunction function! s:ComplFilter(filter) let files = s:FindFilter('*') let files = substitute(files, \ '\(^\|\n\).\{-}compiler[\\/]BTW[-_\\/]\(.\{-}\)\.vim\>\ze\%(\n\|$\)', \ '\1\2', 'g') return files endfunction function! s:Add() endfunction let s:v1 = 'v1' let s:v2 = 2 function! s:Foo(i) return a:i*a:i endfunction function! s:echo(params) echo s:{join(a:params, '')} endfunction function! Echo(params) " echo "Echo(".string(a:params).')' let expr = 's:'.join(a:params, '') " echo expr exe 'echo '.expr endfunction let TBTWcommand = { \ "name" : "TBT", \ "arg_type" : "sub_commands", \ "arguments" : \ [ \ { "name" : "echo", \ "arg_type" : "function", \ "arguments" : "v1,v2", \ "action": function("\<sid>echo") }, \ { "name" : "Echo", \ "arg_type" : "function", \ "arguments" : "v1,v2", \ "action": function("Echo") }, \ { "name" : "help" }, \ { "name" : "add", \ "arguments": function("s:ComplFilter"), \ "action" : function("s:Add") } \ ] \ } call lh#command#new(TBTWcommand) nnoremap µ :call lh#command#new(TBTWcommand)<cr> "============================================================================= " vim600: set fdm=marker: