local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local feed = helpers.feed
local clear = helpers.clear
local command = helpers.command
local insert = helpers.insert
local write_file = helpers.write_file
local exec = helpers.exec
describe('Diff mode screen', function()
local fname = 'Xtest-functional-diff-screen-1'
local fname_2 = fname .. '.2'
local screen
local reread = function()
feed(':e<cr><c-w>w:e<cr><c-w>w')
end
setup(function()
clear()
os.remove(fname)
os.remove(fname_2)
end)
teardown(function()
os.remove(fname)
os.remove(fname_2)
end)
before_each(function()
clear()
feed(':e ' .. fname_2 .. '<cr>')
feed(':vnew ' .. fname .. '<cr>')
feed(':diffthis<cr>')
feed('<c-w>w:diffthis<cr><c-w>w')
screen = Screen.new(40, 16)
screen:attach()
screen:set_default_attr_ids({
[1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
[2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
[3] = {reverse = true},
[4] = {background = Screen.colors.LightBlue},
[5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
[6] = {bold = true, foreground = Screen.colors.Blue1},
[7] = {bold = true, reverse = true},
[8] = {bold = true, background = Screen.colors.Red},
[9] = {background = Screen.colors.LightMagenta},
})
end)
it('Add a line in beginning of file 2', function()
write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
write_file(fname_2, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
reread()
feed(':set diffopt=filler<cr>')
screen:expect([[
{1: }{2:------------------}│{1: }{4:0 }|
{1: }^1 │{1: }1 |
{1: }2 │{1: }2 |
{1: }3 │{1: }3 |
{1: }4 │{1: }4 |
{1: }5 │{1: }5 |
{1: }6 │{1: }6 |
{1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
:set diffopt=filler |
]])
feed(':set diffopt+=internal<cr>')
screen:expect([[
{1: }{2:------------------}│{1: }{4:0 }|
{1: }^1 │{1: }1 |
{1: }2 │{1: }2 |
{1: }3 │{1: }3 |
{1: }4 │{1: }4 |
{1: }5 │{1: }5 |
{1: }6 │{1: }6 |
{1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{6:~ }│{6:~ }|
{7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
:set diffopt+=internal |
]])
end)
it('Add a line in beginning of file 1', function()
write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n
|