aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-23 09:10:16 +0800
committerGitHub <noreply@github.com>2024-05-23 09:10:16 +0800
commitcd48b72b60af0a8b5a7770ab599e4062e974183d (patch)
tree0e45682fe3539497e002d424491841a593cc3ea1
parent8802bf875a497d1ce47d74cc2fa33d3ab28c11c0 (diff)
downloadrneovim-cd48b72b60af0a8b5a7770ab599e4062e974183d.tar.gz
rneovim-cd48b72b60af0a8b5a7770ab599e4062e974183d.tar.bz2
rneovim-cd48b72b60af0a8b5a7770ab599e4062e974183d.zip
fix(shada): restore search pattern length properly (#28929)
-rw-r--r--src/nvim/shada.c1
-rw-r--r--test/functional/shada/history_spec.lua12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 490ab2b050..6f2eefeb92 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -1188,6 +1188,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
.off = cur_entry.data.search_pattern.offset,
},
.pat = cur_entry.data.search_pattern.pat,
+ .patlen = strlen(cur_entry.data.search_pattern.pat),
.additional_data = cur_entry.data.search_pattern.additional_data,
.timestamp = cur_entry.timestamp,
};
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index 1ad230f244..39a5f8df7e 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -116,6 +116,12 @@ describe('ShaDa support code', function()
nvim_feed('gg0n')
eq({ 0, 2, 3, 0 }, fn.getpos('.'))
eq(1, api.nvim_get_vvar('searchforward'))
+ -- Autocommands shouldn't cause search pattern to change
+ nvim_command('autocmd User * :')
+ nvim_command('doautocmd User')
+ nvim_feed('gg0n')
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
+ eq(1, api.nvim_get_vvar('searchforward'))
end)
it('dumps and loads last search pattern with offset and backward direction', function()
@@ -130,6 +136,12 @@ describe('ShaDa support code', function()
nvim_feed('G$n')
eq({ 0, 2, 3, 0 }, fn.getpos('.'))
eq(0, api.nvim_get_vvar('searchforward'))
+ -- Autocommands shouldn't cause search pattern to change
+ nvim_command('autocmd User * :')
+ nvim_command('doautocmd User')
+ nvim_feed('G$n')
+ eq({ 0, 2, 3, 0 }, fn.getpos('.'))
+ eq(0, api.nvim_get_vvar('searchforward'))
end)
it('saves v:hlsearch=1', function()