mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 11:45:01 -07:00
d31d177a0c
Calling cmd.exe in Windows follows a very different pattern from Vim. The primary difference is that Vim does a nested call to cmd.exe, e.g. the following call in Vim system('echo a 2>&1') spawns the following processes "C:\Program Files (x86)\Vim\vim80\vimrun" -s C:\Windows\system32\cmd.exe /c (echo a 2^>^&1 ^>C:\Users\dummy\AppData\Local\Temp\VIoC169.tmp 2^>^&1) C:\Windows\system32\cmd.exe /c C:\Windows\system32\cmd.exe /c (echo a 2^>^&1 ^>C:\Users\dummy\AppData\Local\Temp\VIo3C6C.tmp 2^>^&1) C:\Windows\system32\cmd.exe /c (echo a 2>&1 >C:\Users\dummy\AppData\Local\Temp\VIo3C6C.tmp 2>&1) The escaping with ^ is needed because cmd.exe calls itself and needs to preserve the special metacharacters for the last call. However in nvim no nested call is made, system('') spawns a single cmd.exe process. Setting shellxescape to "" disables escaping with ^. The previous default for shellxquote=( wrapped any command in parenthesis, in Vim this is more meaningful due to the use of tempfiles to store the output and redirection (also see &shellquote). There is a slight benefit in having the default be empty because some expressions that run in console will not run within parens e.g. due to unbalanced double quotes system('echo "a b')
69 lines
2.2 KiB
Lua
69 lines
2.2 KiB
Lua
local helpers = require('test.functional.helpers')(after_each)
|
|
local screen = require('test.functional.ui.screen')
|
|
|
|
local curbufmeths = helpers.curbufmeths
|
|
local curwinmeths = helpers.curwinmeths
|
|
local nvim_dir = helpers.nvim_dir
|
|
local command = helpers.command
|
|
local meths = helpers.meths
|
|
local clear = helpers.clear
|
|
local eq = helpers.eq
|
|
|
|
describe(':edit term://*', function()
|
|
local get_screen = function(columns, lines)
|
|
local scr = screen.new(columns, lines)
|
|
scr:attach({rgb=false})
|
|
return scr
|
|
end
|
|
|
|
before_each(function()
|
|
clear()
|
|
meths.set_option('shell', nvim_dir .. '/shell-test')
|
|
meths.set_option('shellcmdflag', 'EXE')
|
|
end)
|
|
|
|
it('runs TermOpen event', function()
|
|
meths.set_var('termopen_runs', {})
|
|
command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
|
|
command('edit term://')
|
|
local termopen_runs = meths.get_var('termopen_runs')
|
|
eq(1, #termopen_runs)
|
|
eq(termopen_runs[1], termopen_runs[1]:match('^term://.//%d+:$'))
|
|
end)
|
|
|
|
it("runs TermOpen early enough to set buffer-local 'scrollback'", function()
|
|
local columns, lines = 20, 4
|
|
local scr = get_screen(columns, lines)
|
|
local rep = 'a'
|
|
meths.set_option('shellcmdflag', 'REP ' .. rep)
|
|
local rep_size = rep:byte() -- 'a' => 97
|
|
local sb = 10
|
|
command('autocmd TermOpen * :setlocal scrollback='..tostring(sb)
|
|
..'|call feedkeys("G", "n")')
|
|
command('edit term://foobar')
|
|
|
|
local bufcontents = {}
|
|
local winheight = curwinmeths.get_height()
|
|
local buf_cont_start = rep_size - sb - winheight + 2
|
|
for i = buf_cont_start,(rep_size - 1) do
|
|
bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i)
|
|
end
|
|
bufcontents[#bufcontents + 1] = ''
|
|
bufcontents[#bufcontents + 1] = '[Process exited 0]'
|
|
|
|
local exp_screen = '\n'
|
|
for i = 1,(winheight - 1) do
|
|
local line = bufcontents[#bufcontents - winheight + i]
|
|
exp_screen = (exp_screen
|
|
.. line
|
|
.. (' '):rep(columns - #line)
|
|
.. '|\n')
|
|
end
|
|
exp_screen = exp_screen..'^[Process exited 0] |\n'
|
|
|
|
exp_screen = exp_screen..(' '):rep(columns)..'|\n'
|
|
scr:expect(exp_screen)
|
|
eq(bufcontents, curbufmeths.get_lines(0, -1, true))
|
|
end)
|
|
end)
|