mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
shada: Make sure that shada-r option correctly ignores case
This commit is contained in:
@@ -72,6 +72,8 @@ KHASH_SET_INIT_STR(strset)
|
|||||||
home_replace(a, (char_u *)b, (char_u *)c, d, e)
|
home_replace(a, (char_u *)b, (char_u *)c, d, e)
|
||||||
#define vim_rename(a, b) \
|
#define vim_rename(a, b) \
|
||||||
(vim_rename((char_u *)a, (char_u *)b))
|
(vim_rename((char_u *)a, (char_u *)b))
|
||||||
|
#define mb_strnicmp(a, b, c) \
|
||||||
|
(mb_strnicmp((char_u *)a, (char_u *)b, c))
|
||||||
#define has_non_ascii(a) (has_non_ascii((char_u *)a))
|
#define has_non_ascii(a) (has_non_ascii((char_u *)a))
|
||||||
#define string_convert(a, b, c) \
|
#define string_convert(a, b, c) \
|
||||||
((char *)string_convert((vimconv_T *)a, (char_u *)b, c))
|
((char *)string_convert((vimconv_T *)a, (char_u *)b, c))
|
||||||
@@ -4014,7 +4016,7 @@ bool shada_removable(const char *name)
|
|||||||
if (part[0] == 'r') {
|
if (part[0] == 'r') {
|
||||||
home_replace(NULL, part + 1, NameBuff, MAXPATHL, true);
|
home_replace(NULL, part + 1, NameBuff, MAXPATHL, true);
|
||||||
size_t n = STRLEN(NameBuff);
|
size_t n = STRLEN(NameBuff);
|
||||||
if (STRNICMP(NameBuff, new_name, n) == 0) {
|
if (mb_strnicmp(NameBuff, new_name, n) == 0) {
|
||||||
retval = true;
|
retval = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -148,6 +148,23 @@ describe('ShaDa support code', function()
|
|||||||
os.remove('NONE')
|
os.remove('NONE')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local marklike = {[7]=true, [8]=true, [10]=true, [11]=true}
|
||||||
|
local find_file = function(fname)
|
||||||
|
local found = {}
|
||||||
|
for _, v in ipairs(read_shada_file(shada_fname)) do
|
||||||
|
if marklike[v.type] and v.value.f == fname then
|
||||||
|
found[v.type] = (found[v.type] or 0) + 1
|
||||||
|
elseif v.type == 9 then
|
||||||
|
for _, b in ipairs(v.value) do
|
||||||
|
if b.f == fname then
|
||||||
|
found[v.type] = (found[v.type] or 0) + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return found
|
||||||
|
end
|
||||||
|
|
||||||
it('correctly uses shada-r option', function()
|
it('correctly uses shada-r option', function()
|
||||||
nvim('set_var', '__home', paths.test_source_path)
|
nvim('set_var', '__home', paths.test_source_path)
|
||||||
nvim_command('let $HOME = __home')
|
nvim_command('let $HOME = __home')
|
||||||
@@ -157,32 +174,33 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('undo')
|
nvim_command('undo')
|
||||||
nvim_command('set shada+=%')
|
nvim_command('set shada+=%')
|
||||||
nvim_command('wshada! ' .. shada_fname)
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
local marklike = {[7]=true, [8]=true, [10]=true, [11]=true}
|
|
||||||
local readme_fname = paths.test_source_path .. '/README.md'
|
local readme_fname = paths.test_source_path .. '/README.md'
|
||||||
local find_readme = function()
|
eq({[7]=1, [8]=2, [9]=1, [10]=4, [11]=1}, find_file(readme_fname))
|
||||||
local found = {}
|
|
||||||
for _, v in ipairs(read_shada_file(shada_fname)) do
|
|
||||||
if marklike[v.type] and v.value.f == readme_fname then
|
|
||||||
found[v.type] = (found[v.type] or 0) + 1
|
|
||||||
elseif v.type == 9 then
|
|
||||||
for _, b in ipairs(v.value) do
|
|
||||||
if b.f == readme_fname then
|
|
||||||
found[v.type] = (found[v.type] or 0) + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return found
|
|
||||||
end
|
|
||||||
eq({[7]=1, [8]=2, [9]=1, [10]=4, [11]=1}, find_readme())
|
|
||||||
nvim_command('set shada+=r~')
|
nvim_command('set shada+=r~')
|
||||||
nvim_command('wshada! ' .. shada_fname)
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
eq({}, find_readme())
|
eq({}, find_file(readme_fname))
|
||||||
nvim_command('set shada-=r~')
|
nvim_command('set shada-=r~')
|
||||||
nvim_command('wshada! ' .. shada_fname)
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
eq({[7]=1, [8]=2, [9]=1, [10]=4, [11]=1}, find_readme())
|
eq({[7]=1, [8]=2, [9]=1, [10]=4, [11]=1}, find_file(readme_fname))
|
||||||
nvim_command('set shada+=r' .. paths.test_source_path)
|
nvim_command('set shada+=r' .. paths.test_source_path)
|
||||||
nvim_command('wshada! ' .. shada_fname)
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
eq({}, find_readme())
|
eq({}, find_file(readme_fname))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('correctly ignores case with shada-r option', function()
|
||||||
|
local pwd = nvim('call_function', 'getcwd', {})
|
||||||
|
local relfname = 'абв/test'
|
||||||
|
local fname = pwd .. '/' .. relfname
|
||||||
|
nvim('set_var', '__fname', fname)
|
||||||
|
nvim_command('silent! edit `=__fname`')
|
||||||
|
nvim('call_function', 'setline', {1, {'a', 'b', 'c', 'd'}})
|
||||||
|
nvim_command('normal! GmAggmaAabc')
|
||||||
|
nvim_command('undo')
|
||||||
|
nvim_command('set shada+=%')
|
||||||
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
|
eq({[7]=1, [8]=2, [9]=1, [10]=4, [11]=2}, find_file(fname))
|
||||||
|
nvim_command('set shada+=r' .. pwd .. '/АБВ')
|
||||||
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
|
eq({}, find_file(fname))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user