~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to test/functional/terminal/edit_spec.lua

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
local helpers = require('test.functional.helpers')
 
2
local screen = require('test.functional.ui.screen')
 
3
 
 
4
local curbufmeths = helpers.curbufmeths
 
5
local curwinmeths = helpers.curwinmeths
 
6
local nvim_dir = helpers.nvim_dir
 
7
local command = helpers.command
 
8
local meths = helpers.meths
 
9
local clear = helpers.clear
 
10
local eq = helpers.eq
 
11
 
 
12
describe(':edit term://*', function()
 
13
  local get_screen = function(columns, lines)
 
14
    local scr = screen.new(columns, lines)
 
15
    scr:attach(false)
 
16
    return scr
 
17
  end
 
18
 
 
19
  before_each(function()
 
20
    clear()
 
21
    meths.set_option('shell', nvim_dir .. '/shell-test')
 
22
    meths.set_option('shellcmdflag', 'EXE')
 
23
  end)
 
24
 
 
25
  it('runs TermOpen event', function()
 
26
    meths.set_var('termopen_runs', {})
 
27
    command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
 
28
    command('edit term://')
 
29
    local termopen_runs = meths.get_var('termopen_runs')
 
30
    eq(1, #termopen_runs)
 
31
    eq(termopen_runs[1], termopen_runs[1]:match('^term://.//%d+:$'))
 
32
  end)
 
33
 
 
34
  it('runs TermOpen early enough to respect terminal_scrollback_buffer_size', function()
 
35
    local columns, lines = 20, 4
 
36
    local scr = get_screen(columns, lines)
 
37
    local rep = 'a'
 
38
    meths.set_option('shellcmdflag', 'REP ' .. rep)
 
39
    local rep_size = rep:byte()
 
40
    local sb = 10
 
41
    local gsb = 20
 
42
    meths.set_var('terminal_scrollback_buffer_size', gsb)
 
43
    command('autocmd TermOpen * :let b:terminal_scrollback_buffer_size = '
 
44
            .. tostring(sb))
 
45
    command('edit term://foobar')
 
46
    local bufcontents = {}
 
47
    local winheight = curwinmeths.get_height()
 
48
    -- I have no idea why there is + 4 needed. But otherwise it works fine with 
 
49
    -- different scrollbacks.
 
50
    local shift = -4
 
51
    local buf_cont_start = rep_size - 1 - sb - winheight - shift
 
52
    local bufline = function(i) return ('%d: foobar'):format(i) end
 
53
    for i = buf_cont_start,(rep_size - 1) do
 
54
      bufcontents[#bufcontents + 1] = bufline(i)
 
55
    end
 
56
    bufcontents[#bufcontents + 1] = ''
 
57
    bufcontents[#bufcontents + 1] = '[Process exited 0]'
 
58
    -- Do not ask me why displayed screen is one line *before* buffer
 
59
    -- contents: buffer starts with 87:, screen with 86:.
 
60
    local exp_screen = '\n'
 
61
    local did_cursor = false
 
62
    for i = 0,(winheight - 1) do
 
63
      local line = bufline(buf_cont_start + i - 1)
 
64
      exp_screen = (exp_screen
 
65
                    .. (did_cursor and '' or '^')
 
66
                    .. line
 
67
                    .. (' '):rep(columns - #line)
 
68
                    .. '|\n')
 
69
      did_cursor = true
 
70
    end
 
71
    exp_screen = exp_screen .. (' '):rep(columns) .. '|\n'
 
72
    scr:expect(exp_screen)
 
73
    eq(bufcontents, curbufmeths.get_lines(1, -1, true))
 
74
  end)
 
75
end)