view src/testdir/view_util.vim @ 10845:c31782d57569 v8.0.0312

patch 8.0.0312: failure when a channel receives a split json message commit https://github.com/vim/vim/commit/88989cc381c764978f7d7c8e387f3efc21333b4b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 6 21:56:09 2017 +0100 patch 8.0.0312: failure when a channel receives a split json message Problem: When a json message arrives in pieces, the start is dropped and the decoding fails. Solution: Do not drop the start when it is still needed. (Kay Zheng) Add a test. Reset the timeout when something is received.
author Christian Brabandt <cb@256bit.org>
date Mon, 06 Feb 2017 22:00:05 +0100
parents 678edb254216
children ba55861aa52c
line wrap: on
line source

" 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