mirror of
https://github.com/neovim/neovim.git
synced 2026-07-25 02:10:45 +00:00
Problem: Continue separators normalization, and try to keep it at the nvim <-> external boundary, e.g., `fn.xxx`, `api.xxx`, `:xxx` Solution: some key changes - normalize `$HOME-windows` - normalize entry points of changing directory - `nvim_set_current_dir()`, `chdir()` - normalize the named pipe - `--listen` arg, `--server` arg, `:restart` - `serverstart()`, `sockconnect()`, `serverstop()` - make `expand()` respect 'shellslash' again - clean up `did_set_shellslash` - replace `forward_slash` with `TO_SLASH` - remove obsolete `TMP_PATHSEPSTR` - remove `slash_adjust` in `do_autocmd_dirchanged`? - make `fnamemodify()` always return `/` (except when substituting separators via `:s`, `:gs` ?) Note: - these funcs still apply `slash_adjust` on return, as before: `:pwd`, `chdir()`, `exepath()`, `getcwd()` - these funcs alwarys return `/`, unlike before the normalization PRs - `getcompletion()`, `finddir()`, `findfile()` Also - clean up code, comments, formatting and tests - move `TO_SLASH` from `f_chdir` to `changedir_func` - move `TO_SLASH` from `f_bufadd` to `buflist_new` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
64 lines
2.1 KiB
Lua
64 lines
2.1 KiB
Lua
local t = require('test.testutil')
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local testprg = n.testprg
|
|
local command = n.command
|
|
local fn = n.fn
|
|
local api = n.api
|
|
local clear = n.clear
|
|
local eq = t.eq
|
|
local matches = t.matches
|
|
local pesc = vim.pesc
|
|
|
|
describe(':edit term://*', function()
|
|
before_each(function()
|
|
clear()
|
|
api.nvim_set_option_value('shell', testprg('shell-test'), {})
|
|
api.nvim_set_option_value('shellcmdflag', 'EXE', {})
|
|
end)
|
|
|
|
it('runs TermOpen event', function()
|
|
api.nvim_set_var('termopen_runs', {})
|
|
command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
|
|
command('edit term://')
|
|
local termopen_runs = api.nvim_get_var('termopen_runs')
|
|
eq(1, #termopen_runs)
|
|
local cwd = fn.fnamemodify('.', ':p:~'):gsub([[/*$]], '')
|
|
matches('^term://' .. pesc(cwd) .. '//%d+:$', termopen_runs[1])
|
|
end)
|
|
|
|
it("runs TermOpen early enough to set buffer-local 'scrollback'", function()
|
|
local columns, lines = 20, 4
|
|
local scr = Screen.new(columns, lines, { rgb = false })
|
|
local rep = 97
|
|
api.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {})
|
|
command('set shellxquote=') -- win: avoid extra quotes
|
|
local sb = 10
|
|
command(
|
|
'autocmd TermOpen * :setlocal scrollback=' .. tostring(sb) .. '|call feedkeys("G", "n")'
|
|
)
|
|
command('edit term://foobar')
|
|
|
|
local bufcontents = {}
|
|
local winheight = api.nvim_win_get_height(0)
|
|
local buf_cont_start = rep - sb - winheight + 1
|
|
for i = buf_cont_start, (rep - 1) do
|
|
bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i)
|
|
end
|
|
bufcontents[#bufcontents + 1] = ''
|
|
|
|
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, api.nvim_buf_get_lines(0, 0, -1, true))
|
|
end)
|
|
end)
|