mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 20:38:18 +00:00
fix(shada): don't store empty replacement string
This commit is contained in:
@@ -2417,6 +2417,7 @@ static ShaDaWriteResult shada_write(FileDescriptor *const sd_writer,
|
|||||||
// Initialize substitute replacement string
|
// Initialize substitute replacement string
|
||||||
SubReplacementString sub;
|
SubReplacementString sub;
|
||||||
sub_get_replacement(&sub);
|
sub_get_replacement(&sub);
|
||||||
|
if (sub.sub != NULL) { // Don't store empty replacement string
|
||||||
wms->replacement = (PossiblyFreedShadaEntry) {
|
wms->replacement = (PossiblyFreedShadaEntry) {
|
||||||
.can_free_entry = false,
|
.can_free_entry = false,
|
||||||
.data = {
|
.data = {
|
||||||
@@ -2431,6 +2432,7 @@ static ShaDaWriteResult shada_write(FileDescriptor *const sd_writer,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize global marks
|
// Initialize global marks
|
||||||
if (dump_global_marks) {
|
if (dump_global_marks) {
|
||||||
|
@@ -239,9 +239,10 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('silent! /«/')
|
nvim_command('silent! /«/')
|
||||||
expect_exit(nvim_command, 'qall!')
|
expect_exit(nvim_command, 'qall!')
|
||||||
reset()
|
reset()
|
||||||
fn.setline('.', { '\171«' })
|
fn.setline('.', { 'foo', '\171«' })
|
||||||
nvim_command('~&')
|
nvim_feed('gg0n')
|
||||||
eq('\171', fn.getline('.'))
|
eq({ 0, 2, 2, 0 }, fn.getpos('.'))
|
||||||
|
eq('\171«', fn.getline('.'))
|
||||||
eq('', fn.histget('/', -1))
|
eq('', fn.histget('/', -1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -250,9 +251,10 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('silent! /\171/')
|
nvim_command('silent! /\171/')
|
||||||
expect_exit(nvim_command, 'qall!')
|
expect_exit(nvim_command, 'qall!')
|
||||||
reset()
|
reset()
|
||||||
fn.setline('.', { '\171«' })
|
fn.setline('.', { 'foo', '\171«' })
|
||||||
nvim_command('~&')
|
nvim_feed('gg0n')
|
||||||
eq('«', fn.getline('.'))
|
eq({ 0, 2, 1, 0 }, fn.getpos('.'))
|
||||||
|
eq('\171«', fn.getline('.'))
|
||||||
eq('', fn.histget('/', -1))
|
eq('', fn.histget('/', -1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -277,4 +279,14 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('does not dump empty replacement string', function()
|
||||||
|
expect_exit(nvim_command, 'qall!')
|
||||||
|
reset()
|
||||||
|
fn.setline('.', { 'foo', 'bar' })
|
||||||
|
nvim_command('language C')
|
||||||
|
nvim_feed('/f\n')
|
||||||
|
local err = pcall_err(nvim_command, '~&')
|
||||||
|
eq('Vim(~):E33: No previous substitute regular expression', err)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user