mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
shada: When using shada-r normalize option path
This commit is contained in:
@@ -5374,8 +5374,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
specifies the start of a path for which no marks will be
|
specifies the start of a path for which no marks will be
|
||||||
stored. This is to avoid removable media. For MS-DOS you
|
stored. This is to avoid removable media. For MS-DOS you
|
||||||
could use "ra:,rb:". You can also use it for temp files,
|
could use "ra:,rb:". You can also use it for temp files,
|
||||||
e.g., for Unix: "r/tmp". Case is ignored. Maximum length of
|
e.g., for Unix: "r/tmp". Case is ignored.
|
||||||
each 'r' argument is 50 characters.
|
|
||||||
*shada-s*
|
*shada-s*
|
||||||
s Maximum size of an item contents in KiB. If zero then nothing
|
s Maximum size of an item contents in KiB. If zero then nothing
|
||||||
is saved. Unlike Vim this applies to all items, except for
|
is saved. Unlike Vim this applies to all items, except for
|
||||||
|
@@ -68,6 +68,8 @@ KHASH_SET_INIT_STR(strset)
|
|||||||
#define emsgu(a, ...) emsgu((char_u *) a, __VA_ARGS__)
|
#define emsgu(a, ...) emsgu((char_u *) a, __VA_ARGS__)
|
||||||
#define home_replace_save(a, b) \
|
#define home_replace_save(a, b) \
|
||||||
((char *)home_replace_save(a, (char_u *)b))
|
((char *)home_replace_save(a, (char_u *)b))
|
||||||
|
#define home_replace(a, b, 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 has_non_ascii(a) (has_non_ascii((char_u *)a))
|
#define has_non_ascii(a) (has_non_ascii((char_u *)a))
|
||||||
@@ -4003,16 +4005,16 @@ bool shada_removable(const char *name)
|
|||||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char part[51];
|
char part[MAXPATHL + 1];
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
size_t n;
|
|
||||||
|
|
||||||
char *new_name = home_replace_save(NULL, name);
|
char *new_name = home_replace_save(NULL, name);
|
||||||
for (p = (char *) p_shada; *p; ) {
|
for (p = (char *) p_shada; *p; ) {
|
||||||
(void) copy_option_part(&p, part, 51, ", ");
|
(void) copy_option_part(&p, part, ARRAY_SIZE(part), ", ");
|
||||||
if (part[0] == 'r') {
|
if (part[0] == 'r') {
|
||||||
n = STRLEN(part + 1);
|
home_replace(NULL, part + 1, NameBuff, MAXPATHL, true);
|
||||||
if (STRNICMP(part + 1, new_name, n) == 0) {
|
size_t n = STRLEN(NameBuff);
|
||||||
|
if (STRNICMP(NameBuff, new_name, n) == 0) {
|
||||||
retval = true;
|
retval = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ end
|
|||||||
|
|
||||||
module.test_include_path = "${CMAKE_BINARY_DIR}/test/includes/post"
|
module.test_include_path = "${CMAKE_BINARY_DIR}/test/includes/post"
|
||||||
module.test_libnvim_path = "${TEST_LIBNVIM_PATH}"
|
module.test_libnvim_path = "${TEST_LIBNVIM_PATH}"
|
||||||
|
module.test_source_path = "${CMAKE_SOURCE_DIR}"
|
||||||
table.insert(module.include_paths, "${CMAKE_BINARY_DIR}/include")
|
table.insert(module.include_paths, "${CMAKE_BINARY_DIR}/include")
|
||||||
|
|
||||||
return module
|
return module
|
||||||
|
@@ -7,6 +7,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
|
|||||||
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog,
|
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog,
|
||||||
helpers.exc_exec
|
helpers.exc_exec
|
||||||
local lfs = require('lfs')
|
local lfs = require('lfs')
|
||||||
|
local paths = require('test.config.paths')
|
||||||
|
|
||||||
local msgpack = require('MessagePack')
|
local msgpack = require('MessagePack')
|
||||||
|
|
||||||
@@ -146,4 +147,42 @@ describe('ShaDa support code', function()
|
|||||||
session:exit(0)
|
session:exit(0)
|
||||||
os.remove('NONE')
|
os.remove('NONE')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('correctly uses shada-r option', function()
|
||||||
|
nvim('set_var', '__home', paths.test_source_path)
|
||||||
|
nvim_command('let $HOME = __home')
|
||||||
|
nvim_command('unlet __home')
|
||||||
|
nvim_command('edit ~/README.md')
|
||||||
|
nvim_command('normal! GmAggmaAabc')
|
||||||
|
nvim_command('undo')
|
||||||
|
nvim_command('set shada+=%')
|
||||||
|
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 find_readme = function()
|
||||||
|
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('wshada! ' .. shada_fname)
|
||||||
|
eq({}, find_readme())
|
||||||
|
nvim_command('set shada-=r~')
|
||||||
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
|
eq({[7]=1, [8]=2, [9]=1, [10]=4, [11]=1}, find_readme())
|
||||||
|
nvim_command('set shada+=r' .. paths.test_source_path)
|
||||||
|
nvim_command('wshada! ' .. shada_fname)
|
||||||
|
eq({}, find_readme())
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user