Merge remote-tracking branch 'upstream/master'

This commit is contained in:
ckelsel 2017-10-07 18:14:09 +08:00
commit f2b9ccec10
14 changed files with 224 additions and 116 deletions

View File

@ -7,6 +7,10 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
charset = utf_8 charset = utf_8
[runtime/doc/*.txt]
indent_style = tab
indent_size = 8
[Makefile] [Makefile]
indent_style = tab indent_style = tab
tab_width = 4 tab_width = 4

View File

@ -1,4 +1,6 @@
version: '{build}' version: '{build}'
environment:
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: "-t7z -m0=lzma -mx=9"
configuration: configuration:
- MINGW_64 - MINGW_64
- MINGW_32 - MINGW_32

View File

@ -46,6 +46,7 @@ check_c_source_compiles("
int main(int argc, char** argv) { int main(int argc, char** argv) {
gettext(\"foo\"); gettext(\"foo\");
ngettext(\"foo\", \"bar\", 1);
bindtextdomain(\"foo\", \"bar\"); bindtextdomain(\"foo\", \"bar\");
bind_textdomain_codeset(\"foo\", \"bar\"); bind_textdomain_codeset(\"foo\", \"bar\");
textdomain(\"foo\"); textdomain(\"foo\");

View File

@ -6267,11 +6267,11 @@ A jump table for the options with a short description can be found at |Q_op|.
when part of a command has been typed. when part of a command has been typed.
*'title'* *'notitle'* *'title'* *'notitle'*
'title' boolean (default off, on when title can be restored) 'title' boolean (default off)
global global
When on, the title of the window will be set to the value of When on, the title of the window will be set to the value of
'titlestring' (if it is not empty), or to: 'titlestring' (if it is not empty), or to:
filename [+=-] (path) - VIM filename [+=-] (path) - NVIM
Where: Where:
filename the name of the file being edited filename the name of the file being edited
- indicates the file cannot be modified, 'ma' off - indicates the file cannot be modified, 'ma' off
@ -6279,7 +6279,7 @@ A jump table for the options with a short description can be found at |Q_op|.
= indicates the file is read-only = indicates the file is read-only
=+ indicates the file is read-only and modified =+ indicates the file is read-only and modified
(path) is the path of the file being edited (path) is the path of the file being edited
- VIM the server name |v:servername| or "VIM" - NVIM the server name |v:servername| or "NVIM"
*'titlelen'* *'titlelen'*
'titlelen' number (default 85) 'titlelen' number (default 85)
@ -6295,11 +6295,10 @@ A jump table for the options with a short description can be found at |Q_op|.
'titlelen' is also used for the 'titlestring' option. 'titlelen' is also used for the 'titlestring' option.
*'titleold'* *'titleold'*
'titleold' string (default "Thanks for flying Vim") 'titleold' string (default "")
global global
This option will be used for the window title when exiting Vim if the If not empty, this option will be used to set the window title when
original title cannot be restored. Only happens if 'title' is on or exiting. Only if 'title' is enabled.
'titlestring' is not empty.
This option cannot be set from a |modeline| or in the |sandbox|, for This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons. security reasons.
*'titlestring'* *'titlestring'*

View File

@ -3069,9 +3069,13 @@ static bool ti_change(char_u *str, char_u **last)
/// Set current window title /// Set current window title
void resettitle(void) void resettitle(void)
{ {
ui_call_set_title(cstr_as_string((char *)lasttitle)); if (p_icon) {
ui_call_set_icon(cstr_as_string((char *)lasticon)); ui_call_set_icon(cstr_as_string((char *)lasticon));
ui_flush(); }
if (p_title || p_icon) {
ui_call_set_title(cstr_as_string((char *)lasttitle));
ui_flush();
}
} }
# if defined(EXITFREE) # if defined(EXITFREE)

View File

@ -13,6 +13,7 @@
#else #else
# define _(x) ((char *)(x)) # define _(x) ((char *)(x))
# define N_(x) x # define N_(x) x
# define ngettext(x, xs, n) ((n) == 1 ? (x) : (xs))
# define bindtextdomain(x, y) // empty # define bindtextdomain(x, y) // empty
# define bind_textdomain_codeset(x, y) // empty # define bind_textdomain_codeset(x, y) // empty
# define textdomain(x) // empty # define textdomain(x) // empty

View File

@ -649,6 +649,11 @@ void getout(int exitval)
/* Position the cursor again, the autocommands may have moved it */ /* Position the cursor again, the autocommands may have moved it */
ui_cursor_goto((int)Rows - 1, 0); ui_cursor_goto((int)Rows - 1, 0);
// Apply 'titleold'.
if (p_title && *p_titleold != NUL) {
ui_call_set_title(cstr_as_string((char *)p_titleold));
}
#if defined(USE_ICONV) && defined(DYNAMIC_ICONV) #if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
iconv_end(); iconv_end();
#endif #endif

View File

@ -2498,7 +2498,7 @@ return {
no_mkrc=true, no_mkrc=true,
vi_def=true, vi_def=true,
varname='p_titleold', varname='p_titleold',
defaults={if_true={vi=N_("Thanks for flying Vim")}} defaults={if_true={vi=N_("")}}
}, },
{ {
full_name='titlestring', full_name='titlestring',

View File

@ -1690,6 +1690,9 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
if (strlen(fname) > (len - 1)) { if (strlen(fname) > (len - 1)) {
xstrlcpy(buf, fname, len); // truncate xstrlcpy(buf, fname, len); // truncate
#ifdef WIN32
slash_adjust(buf);
#endif
return FAIL; return FAIL;
} }
@ -1702,6 +1705,9 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
if (rv == FAIL) { if (rv == FAIL) {
xstrlcpy(buf, fname, len); // something failed; use the filename xstrlcpy(buf, fname, len); // something failed; use the filename
} }
#ifdef WIN32
slash_adjust(buf);
#endif
return rv; return rv;
} }
@ -2196,11 +2202,11 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf,
// expand it if forced or not an absolute path // expand it if forced or not an absolute path
if (force || !path_is_absolute_path(fname)) { if (force || !path_is_absolute_path(fname)) {
if ((p = vim_strrchr(fname, '/')) != NULL) { if ((p = vim_strrchr(fname, PATHSEP)) != NULL) {
// relative to root // relative to root
if (p == fname) { if (p == fname) {
// only one path component // only one path component
relative_directory[0] = '/'; relative_directory[0] = PATHSEP;
relative_directory[1] = NUL; relative_directory[1] = NUL;
} else { } else {
assert(p >= fname); assert(p >= fname);

View File

@ -0,0 +1,56 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
local iswin = helpers.iswin
describe('path collapse', function()
local targetdir
local expected_path
local function join_path(...)
local pathsep = (iswin() and '\\' or '/')
return table.concat({...}, pathsep)
end
before_each(function()
targetdir = join_path('test', 'functional', 'fixtures')
clear()
command('edit '..join_path(targetdir, 'tty-test.c'))
expected_path = eval('expand("%:p")')
end)
it('with /./ segment #7117', function()
command('edit '..join_path(targetdir, '.', 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ./ prefix #7117', function()
command('edit '..join_path('.', targetdir, 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ./ prefix, after directory change #7117', function()
command('edit '..join_path('.', targetdir, 'tty-test.c'))
command('cd test')
eq(expected_path, eval('expand("%:p")'))
end)
it('with /../ segment #7117', function()
command('edit '..join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ../ and different starting directory #7117', function()
command('cd test')
command('edit '..join_path('..', targetdir, 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ./../ and different starting directory #7117', function()
command('cd test')
command('edit '..join_path('.', '..', targetdir, 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
end)

View File

@ -10,6 +10,13 @@ local read_shada_file = shada_helpers.read_shada_file
local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-compatibility.shada') local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-compatibility.shada')
local mock_file_path = '/a/b/'
local mock_file_path2 = '/d/e/'
if helpers.iswin() then
mock_file_path = 'C:/a/'
mock_file_path2 = 'C:/d/'
end
describe('ShaDa forward compatibility support code', function() describe('ShaDa forward compatibility support code', function()
before_each(reset) before_each(reset)
after_each(function() after_each(function()
@ -114,14 +121,14 @@ describe('ShaDa forward compatibility support code', function()
funcs.garbagecollect(1) funcs.garbagecollect(1)
end) end)
for _, v in ipairs({{name='global mark', mpack='\007\001\018\131\162mX\195\161f\196\006/a/b/c\161nA'}, for _, v in ipairs({{name='global mark', mpack='\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161nA'},
{name='jump', mpack='\008\001\018\131\162mX\195\161f\196\006/a/b/c\161l\002'}, {name='jump', mpack='\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'},
{name='local mark', mpack='\010\001\018\131\162mX\195\161f\196\006/a/b/c\161na'}, {name='local mark', mpack='\010\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161na'},
{name='change', mpack='\011\001\015\130\162mX\195\161f\196\006/a/b/c'}, {name='change', mpack='\011\001\015\130\162mX\195\161f\196\006' .. mock_file_path .. 'c'},
}) do }) do
it('works with ' .. v.name .. ' item with BOOL unknown (mX) key value', function() it('works with ' .. v.name .. ' item with BOOL unknown (mX) key value', function()
nvim_command('silent noautocmd edit /a/b/c') nvim_command('silent noautocmd edit ' .. mock_file_path .. 'c')
eq('/a/b/c', funcs.bufname('%')) eq('' .. mock_file_path .. 'c', funcs.bufname('%'))
funcs.setline('.', {'1', '2', '3'}) funcs.setline('.', {'1', '2', '3'})
wshada(v.mpack) wshada(v.mpack)
eq(0, exc_exec(sdrcmd(true))) eq(0, exc_exec(sdrcmd(true)))
@ -159,12 +166,12 @@ describe('ShaDa forward compatibility support code', function()
if v.name == 'global mark' or v.name == 'local mark' then if v.name == 'global mark' or v.name == 'local mark' then
it('works with ' .. v.name .. ' item with <C-a> name', function() it('works with ' .. v.name .. ' item with <C-a> name', function()
nvim_command('silent noautocmd edit /a/b/c') nvim_command('silent noautocmd edit ' .. mock_file_path .. 'c')
eq('/a/b/c', funcs.bufname('%')) eq('' .. mock_file_path .. 'c', funcs.bufname('%'))
funcs.setline('.', {'1', '2', '3'}) funcs.setline('.', {'1', '2', '3'})
wshada(v.mpack:gsub('n.$', 'n\001') wshada(v.mpack:gsub('n.$', 'n\001')
.. v.mpack:gsub('n.$', 'n\002') .. v.mpack:gsub('n.$', 'n\002')
.. v.mpack:gsub('n.$', 'n\003'):gsub('/a/b/c', '/d/e/f')) .. v.mpack:gsub('n.$', 'n\003'):gsub('' .. mock_file_path .. 'c', '' .. mock_file_path2 .. 'f'))
eq(0, exc_exec(sdrcmd(true))) eq(0, exc_exec(sdrcmd(true)))
nvim_command('wshada ' .. shada_fname) nvim_command('wshada ' .. shada_fname)
local found = 0 local found = 0
@ -307,10 +314,10 @@ describe('ShaDa forward compatibility support code', function()
it('works with buffer list item with BOOL unknown (bX) key', function() it('works with buffer list item with BOOL unknown (bX) key', function()
nvim_command('set shada+=%') nvim_command('set shada+=%')
wshada('\009\000\016\145\130\161f\196\006/a/b/c\162bX\195') wshada('\009\000\016\145\130\161f\196\006' .. mock_file_path .. 'c\162bX\195')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
eq(2, funcs.bufnr('$')) eq(2, funcs.bufnr('$'))
eq('/a/b/c', funcs.bufname(2)) eq('' .. mock_file_path .. 'c', funcs.bufname(2))
os.remove(shada_fname) os.remove(shada_fname)
nvim_command('wshada ' .. shada_fname) nvim_command('wshada ' .. shada_fname)
local found = false local found = false

View File

@ -13,6 +13,11 @@ local read_shada_file = shada_helpers.read_shada_file
local wshada, sdrcmd, shada_fname = local wshada, sdrcmd, shada_fname =
get_shada_rw('Xtest-functional-shada-merging.shada') get_shada_rw('Xtest-functional-shada-merging.shada')
local mock_file_path = '/a/b/'
if helpers.iswin() then
mock_file_path = 'C:/a/'
end
describe('ShaDa history merging code', function() describe('ShaDa history merging code', function()
before_each(reset) before_each(reset)
after_each(function() after_each(function()
@ -512,9 +517,9 @@ describe('ShaDa marks support code', function()
it('uses last A mark with gt timestamp from instance when reading', it('uses last A mark with gt timestamp from instance when reading',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A') nvim_command('normal! `A')
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
@ -522,9 +527,9 @@ describe('ShaDa marks support code', function()
it('uses last A mark with gt timestamp from file when reading with !', it('uses last A mark with gt timestamp from file when reading with !',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd(true))) eq(0, exc_exec(sdrcmd(true)))
nvim_command('normal! `A') nvim_command('normal! `A')
eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
@ -532,9 +537,9 @@ describe('ShaDa marks support code', function()
it('uses last A mark with eq timestamp from instance when reading', it('uses last A mark with eq timestamp from instance when reading',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A') nvim_command('normal! `A')
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
@ -542,9 +547,9 @@ describe('ShaDa marks support code', function()
it('uses last A mark with gt timestamp from file when reading', it('uses last A mark with gt timestamp from file when reading',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\002\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A') nvim_command('normal! `A')
eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
@ -552,15 +557,15 @@ describe('ShaDa marks support code', function()
it('uses last A mark with gt timestamp from instance when writing', it('uses last A mark with gt timestamp from instance when writing',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\000\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
nvim_command('normal! `A') nvim_command('normal! `A')
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 7 and v.value.f == '/a/b/-' then if v.type == 7 and v.value.f == '' .. mock_file_path .. '-' then
found = found + 1 found = found + 1
end end
end end
@ -569,15 +574,15 @@ describe('ShaDa marks support code', function()
it('uses last A mark with eq timestamp from instance when writing', it('uses last A mark with eq timestamp from instance when writing',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
nvim_command('normal! `A') nvim_command('normal! `A')
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 7 and v.value.f == '/a/b/-' then if v.type == 7 and v.value.f == mock_file_path .. '-' then
found = found + 1 found = found + 1
end end
end end
@ -586,15 +591,15 @@ describe('ShaDa marks support code', function()
it('uses last A mark with gt timestamp from file when writing', it('uses last A mark with gt timestamp from file when writing',
function() function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/-\161nA') wshada('\007\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. '-\161nA')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\007\002\018\131\162mX\195\161f\196\006/a/b/?\161nA') wshada('\007\002\018\131\162mX\195\161f\196\006' .. mock_file_path .. '?\161nA')
nvim_command('normal! `A') nvim_command('normal! `A')
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 7 and v.value.f == '/a/b/?' then if v.type == 7 and v.value.f == '' .. mock_file_path .. '?' then
found = found + 1 found = found + 1
end end
end end
@ -603,11 +608,11 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from instance when reading', it('uses last a mark with gt timestamp from instance when reading',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a') nvim_command('normal! `a')
eq('-', funcs.getline('.')) eq('-', funcs.getline('.'))
@ -615,11 +620,11 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from file when reading with !', it('uses last a mark with gt timestamp from file when reading with !',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd(true))) eq(0, exc_exec(sdrcmd(true)))
nvim_command('normal! `a') nvim_command('normal! `a')
eq('?', funcs.getline('.')) eq('?', funcs.getline('.'))
@ -627,11 +632,11 @@ describe('ShaDa marks support code', function()
it('uses last a mark with eq timestamp from instance when reading', it('uses last a mark with eq timestamp from instance when reading',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a') nvim_command('normal! `a')
eq('-', funcs.getline('.')) eq('-', funcs.getline('.'))
@ -639,11 +644,11 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from file when reading', it('uses last a mark with gt timestamp from file when reading',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\002\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a') nvim_command('normal! `a')
eq('?', funcs.getline('.')) eq('?', funcs.getline('.'))
@ -651,17 +656,17 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from instance when writing', it('uses last a mark with gt timestamp from instance when writing',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\000\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
nvim_command('normal! `a') nvim_command('normal! `a')
eq('-', funcs.getline('.')) eq('-', funcs.getline('.'))
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 10 and v.value.f == '/a/b/-' and v.value.n == ('a'):byte() then if v.type == 10 and v.value.f == '' .. mock_file_path .. '-' and v.value.n == ('a'):byte() then
eq(true, v.value.l == 1 or v.value.l == nil) eq(true, v.value.l == 1 or v.value.l == nil)
found = found + 1 found = found + 1
end end
@ -671,17 +676,17 @@ describe('ShaDa marks support code', function()
it('uses last a mark with eq timestamp from instance when writing', it('uses last a mark with eq timestamp from instance when writing',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
nvim_command('normal! `a') nvim_command('normal! `a')
eq('-', funcs.getline('.')) eq('-', funcs.getline('.'))
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 10 and v.value.f == '/a/b/-' and v.value.n == ('a'):byte() then if v.type == 10 and v.value.f == '' .. mock_file_path .. '-' and v.value.n == ('a'):byte() then
eq(true, v.value.l == 1 or v.value.l == nil) eq(true, v.value.l == 1 or v.value.l == nil)
found = found + 1 found = found + 1
end end
@ -691,17 +696,17 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from file when writing', it('uses last a mark with gt timestamp from file when writing',
function() function()
nvim_command('edit /a/b/-') nvim_command('edit ' .. mock_file_path .. '-')
funcs.setline(1, {'-', '?'}) funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na') wshada('\010\001\017\131\161l\001\161f\196\006' .. mock_file_path .. '-\161na')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006/a/b/-\161na') wshada('\010\002\017\131\161l\002\161f\196\006' .. mock_file_path .. '-\161na')
nvim_command('normal! `a') nvim_command('normal! `a')
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 10 and v.value.f == '/a/b/-' and v.value.n == ('a'):byte() then if v.type == 10 and v.value.f == '' .. mock_file_path .. '-' and v.value.n == ('a'):byte() then
eq(2, v.value.l) eq(2, v.value.l)
found = found + 1 found = found + 1
end end
@ -813,41 +818,41 @@ describe('ShaDa jumps support code', function()
end) end)
it('merges jumps when reading', function() it('merges jumps when reading', function()
wshada('\008\001\018\131\162mX\195\161f\196\006/a/b/c\161l\002' wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
.. '\008\004\018\131\162mX\195\161f\196\006/a/b/d\161l\002' .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\002'
.. '\008\007\018\131\162mX\195\161f\196\006/a/b/e\161l\002') .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'e\161l\002')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\008\001\018\131\162mX\195\161f\196\006/a/b/c\161l\002' wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
.. '\008\004\018\131\162mX\195\161f\196\006/a/b/d\161l\003' .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\003'
.. '\008\007\018\131\162mX\195\161f\196\006/a/b/f\161l\002') .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'f\161l\002')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
eq('', curbufmeths.get_name()) eq('', curbufmeths.get_name())
eq('\n' eq('\n'
.. ' jump line col file/text\n' .. ' jump line col file/text\n'
.. ' 6 2 0 /a/b/c\n' .. ' 6 2 0 ' .. mock_file_path .. 'c\n'
.. ' 5 2 0 /a/b/d\n' .. ' 5 2 0 ' .. mock_file_path .. 'd\n'
.. ' 4 3 0 /a/b/d\n' .. ' 4 3 0 ' .. mock_file_path .. 'd\n'
.. ' 3 2 0 /a/b/e\n' .. ' 3 2 0 ' .. mock_file_path .. 'e\n'
.. ' 2 2 0 /a/b/f\n' .. ' 2 2 0 ' .. mock_file_path .. 'f\n'
.. ' 1 1 0 \n' .. ' 1 1 0 \n'
.. '>', redir_exec('jumps')) .. '>', redir_exec('jumps'))
end) end)
it('merges jumps when writing', function() it('merges jumps when writing', function()
wshada('\008\001\018\131\162mX\195\161f\196\006/a/b/c\161l\002' wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
.. '\008\004\018\131\162mX\195\161f\196\006/a/b/d\161l\002' .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\002'
.. '\008\007\018\131\162mX\195\161f\196\006/a/b/e\161l\002') .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'e\161l\002')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\008\001\018\131\162mX\195\161f\196\006/a/b/c\161l\002' wshada('\008\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
.. '\008\004\018\131\162mX\195\161f\196\006/a/b/d\161l\003' .. '\008\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'd\161l\003'
.. '\008\007\018\131\162mX\195\161f\196\006/a/b/f\161l\002') .. '\008\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'f\161l\002')
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local jumps = { local jumps = {
{file='/a/b/c', line=2}, {file='' .. mock_file_path .. 'c', line=2},
{file='/a/b/d', line=2}, {file='' .. mock_file_path .. 'd', line=2},
{file='/a/b/d', line=3}, {file='' .. mock_file_path .. 'd', line=3},
{file='/a/b/e', line=2}, {file='' .. mock_file_path .. 'e', line=2},
{file='/a/b/f', line=2}, {file='' .. mock_file_path .. 'f', line=2},
} }
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
@ -864,9 +869,9 @@ describe('ShaDa jumps support code', function()
local jumps = {} local jumps = {}
local shada = '' local shada = ''
for i = 1,100 do for i = 1,100 do
shada = shada .. ('\008%c\018\131\162mX\195\161f\196\006/a/b/c\161l%c' shada = shada .. ('\008%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'
):format(i, i) ):format(i, i)
jumps[i] = {file='/a/b/c', line=i} jumps[i] = {file='' .. mock_file_path .. 'c', line=i}
end end
wshada(shada) wshada(shada)
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
@ -874,9 +879,9 @@ describe('ShaDa jumps support code', function()
for i = 1,101 do for i = 1,101 do
local t = i * 2 local t = i * 2
shada = shada .. ( shada = shada .. (
'\008\204%c\019\131\162mX\195\161f\196\006/a/b/c\161l\204%c' '\008\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'
):format(t, t) ):format(t, t)
jumps[(t > #jumps + 1) and (#jumps + 1) or t] = {file='/a/b/c', line=t} jumps[(t > #jumps + 1) and (#jumps + 1) or t] = {file='' .. mock_file_path .. 'c', line=t}
end end
wshada(shada) wshada(shada)
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
@ -904,15 +909,15 @@ describe('ShaDa changes support code', function()
end) end)
it('merges changes when reading', function() it('merges changes when reading', function()
nvim_command('edit /a/b/c') nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(7))') nvim_command('keepjumps call setline(1, range(7))')
wshada('\011\001\018\131\162mX\195\161f\196\006/a/b/c\161l\001' wshada('\011\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\001'
.. '\011\004\018\131\162mX\195\161f\196\006/a/b/c\161l\002' .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
.. '\011\007\018\131\162mX\195\161f\196\006/a/b/c\161l\003') .. '\011\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\003')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\011\001\018\131\162mX\194\161f\196\006/a/b/c\161l\001' wshada('\011\001\018\131\162mX\194\161f\196\006' .. mock_file_path .. 'c\161l\001'
.. '\011\004\018\131\162mX\195\161f\196\006/a/b/c\161l\005' .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\005'
.. '\011\008\018\131\162mX\195\161f\196\006/a/b/c\161l\004') .. '\011\008\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\004')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
eq('\n' eq('\n'
.. 'change line col text\n' .. 'change line col text\n'
@ -925,15 +930,15 @@ describe('ShaDa changes support code', function()
end) end)
it('merges changes when writing', function() it('merges changes when writing', function()
nvim_command('edit /a/b/c') nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(7))') nvim_command('keepjumps call setline(1, range(7))')
wshada('\011\001\018\131\162mX\195\161f\196\006/a/b/c\161l\001' wshada('\011\001\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\001'
.. '\011\004\018\131\162mX\195\161f\196\006/a/b/c\161l\002' .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\002'
.. '\011\007\018\131\162mX\195\161f\196\006/a/b/c\161l\003') .. '\011\007\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\003')
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
wshada('\011\001\018\131\162mX\194\161f\196\006/a/b/c\161l\001' wshada('\011\001\018\131\162mX\194\161f\196\006' .. mock_file_path .. 'c\161l\001'
.. '\011\004\018\131\162mX\195\161f\196\006/a/b/c\161l\005' .. '\011\004\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\005'
.. '\011\008\018\131\162mX\195\161f\196\006/a/b/c\161l\004') .. '\011\008\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\004')
eq(0, exc_exec('wshada ' .. shada_fname)) eq(0, exc_exec('wshada ' .. shada_fname))
local changes = { local changes = {
{line=1}, {line=1},
@ -944,7 +949,7 @@ describe('ShaDa changes support code', function()
} }
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 11 and v.value.f == '/a/b/c' then if v.type == 11 and v.value.f == '' .. mock_file_path .. 'c' then
found = found + 1 found = found + 1
eq(changes[found].line, v.value.l or 1) eq(changes[found].line, v.value.l or 1)
end end
@ -953,12 +958,12 @@ describe('ShaDa changes support code', function()
end) end)
it('merges JUMPLISTSIZE changes when writing', function() it('merges JUMPLISTSIZE changes when writing', function()
nvim_command('edit /a/b/c') nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(202))') nvim_command('keepjumps call setline(1, range(202))')
local changes = {} local changes = {}
local shada = '' local shada = ''
for i = 1,100 do for i = 1,100 do
shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006/a/b/c\161l%c' shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'
):format(i, i) ):format(i, i)
changes[i] = {line=i} changes[i] = {line=i}
end end
@ -968,7 +973,7 @@ describe('ShaDa changes support code', function()
for i = 1,101 do for i = 1,101 do
local t = i * 2 local t = i * 2
shada = shada .. ( shada = shada .. (
'\011\204%c\019\131\162mX\195\161f\196\006/a/b/c\161l\204%c' '\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'
):format(t, t) ):format(t, t)
changes[(t > #changes + 1) and (#changes + 1) or t] = {line=t} changes[(t > #changes + 1) and (#changes + 1) or t] = {line=t}
end end
@ -980,7 +985,7 @@ describe('ShaDa changes support code', function()
end end
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 11 and v.value.f == '/a/b/c' then if v.type == 11 and v.value.f == '' .. mock_file_path .. 'c' then
found = found + 1 found = found + 1
eq(changes[found].line, v.value.l) eq(changes[found].line, v.value.l)
end end
@ -990,20 +995,20 @@ describe('ShaDa changes support code', function()
it('merges JUMPLISTSIZE changes when writing, with new items between old', it('merges JUMPLISTSIZE changes when writing, with new items between old',
function() function()
nvim_command('edit /a/b/c') nvim_command('edit ' .. mock_file_path .. 'c')
nvim_command('keepjumps call setline(1, range(202))') nvim_command('keepjumps call setline(1, range(202))')
local shada = '' local shada = ''
for i = 1,101 do for i = 1,101 do
local t = i * 2 local t = i * 2
shada = shada .. ( shada = shada .. (
'\011\204%c\019\131\162mX\195\161f\196\006/a/b/c\161l\204%c' '\011\204%c\019\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l\204%c'
):format(t, t) ):format(t, t)
end end
wshada(shada) wshada(shada)
eq(0, exc_exec(sdrcmd())) eq(0, exc_exec(sdrcmd()))
shada = '' shada = ''
for i = 1,100 do for i = 1,100 do
shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006/a/b/c\161l%c' shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006' .. mock_file_path .. 'c\161l%c'
):format(i, i) ):format(i, i)
end end
local changes = {} local changes = {}
@ -1022,7 +1027,7 @@ describe('ShaDa changes support code', function()
end end
local found = 0 local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == 11 and v.value.f == '/a/b/c' then if v.type == 11 and v.value.f == '' .. mock_file_path .. 'c' then
found = found + 1 found = found + 1
eq(changes[found].line, v.value.l) eq(changes[found].line, v.value.l)
end end
@ -1030,3 +1035,5 @@ describe('ShaDa changes support code', function()
eq(found, 100) eq(found, 100)
end) end)
end) end)
-- vim: ts=2 sw=2

View File

@ -5,6 +5,7 @@ local feed, command = helpers.feed, helpers.command
local insert = helpers.insert local insert = helpers.insert
local eq = helpers.eq local eq = helpers.eq
local eval = helpers.eval local eval = helpers.eval
local iswin = helpers.iswin
describe('screen', function() describe('screen', function()
local screen local screen
@ -119,9 +120,10 @@ describe('Screen', function()
end) end)
it('has correct default title with named file', function() it('has correct default title with named file', function()
local expected = 'myfile (/mydir) - NVIM' local expected = (iswin() and 'myfile (C:\\mydir) - NVIM'
or 'myfile (/mydir) - NVIM')
command('set title') command('set title')
command('file /mydir/myfile') command(iswin() and 'file C:\\mydir\\myfile' or 'file /mydir/myfile')
screen:expect(function() screen:expect(function()
eq(expected, screen.title) eq(expected, screen.title)
end) end)

View File

@ -481,6 +481,20 @@ describe('path.c', function()
eq('/tmp', ffi.string(buffer)) eq('/tmp', ffi.string(buffer))
eq(OK, result) eq(OK, result)
end) end)
itp('expands "./" to the current directory #7117', function()
local force_expansion = 1
local result = vim_FullName('./unit-test-directory/test.file', buffer, length, force_expansion)
eq(OK, result)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
end)
itp('collapses "foo/../foo" to "foo" #7117', function()
local force_expansion = 1
local result = vim_FullName('unit-test-directory/../unit-test-directory/test.file', buffer, length, force_expansion)
eq(OK, result)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
end)
end) end)
describe('path_fix_case', function() describe('path_fix_case', function()