aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/view_util.vim
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-07-29 01:46:43 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-08-12 17:39:06 +0200
commitc747b53f84bfd64ec9f36d4b5912a980a6da8b3e (patch)
tree1bd0e689e6e4e580983b376db655e0f17e5810eb /src/nvim/testdir/view_util.vim
parentb7320471de524ffa0e2ba3f561e4c117c1600b62 (diff)
downloadrneovim-c747b53f84bfd64ec9f36d4b5912a980a6da8b3e.tar.gz
rneovim-c747b53f84bfd64ec9f36d4b5912a980a6da8b3e.tar.bz2
rneovim-c747b53f84bfd64ec9f36d4b5912a980a6da8b3e.zip
vim-patch:8.0.0311
Problem: Linebreak tests are old style. Solution: Turn the tests into new style. Share utility functions. (Ozaki Kiichi, closes vim/vim#1444) https://github.com/vim/vim/commit/544d3bc9f0e494cb712a33b61558b8e8e12b1e0b
Diffstat (limited to 'src/nvim/testdir/view_util.vim')
-rw-r--r--src/nvim/testdir/view_util.vim30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/nvim/testdir/view_util.vim b/src/nvim/testdir/view_util.vim
new file mode 100644
index 0000000000..eb92630761
--- /dev/null
+++ b/src/nvim/testdir/view_util.vim
@@ -0,0 +1,30 @@
+" Functions about view shared by several tests
+
+" ScreenLines(lnum, width) or
+" ScreenLines([start, end], width)
+function! ScreenLines(lnum, width) abort
+ redraw!
+ if type(a:lnum) == v:t_list
+ let start = a:lnum[0]
+ let end = a:lnum[1]
+ else
+ let start = a:lnum
+ let end = a:lnum
+ endif
+ let lines = []
+ for l in range(start, end)
+ let lines += [join(map(range(1, a:width), 'nr2char(screenchar(l, v:val))'), '')]
+ endfor
+ return lines
+endfunction
+
+function! NewWindow(height, width) abort
+ exe a:height . 'new'
+ exe a:width . 'vsp'
+ redraw!
+endfunction
+
+function! CloseWindow() abort
+ bw!
+ redraw!
+endfunction