mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
fix(shada): don't store empty replacement string
This commit is contained in:
@@ -2417,19 +2417,21 @@ 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);
|
||||||
wms->replacement = (PossiblyFreedShadaEntry) {
|
if (sub.sub != NULL) { // Don't store empty replacement string
|
||||||
.can_free_entry = false,
|
wms->replacement = (PossiblyFreedShadaEntry) {
|
||||||
.data = {
|
.can_free_entry = false,
|
||||||
.type = kSDItemSubString,
|
|
||||||
.timestamp = sub.timestamp,
|
|
||||||
.data = {
|
.data = {
|
||||||
.sub_string = {
|
.type = kSDItemSubString,
|
||||||
.sub = sub.sub,
|
.timestamp = sub.timestamp,
|
||||||
}
|
.data = {
|
||||||
},
|
.sub_string = {
|
||||||
.additional_data = sub.additional_data,
|
.sub = sub.sub,
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
.additional_data = sub.additional_data,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize global marks
|
// Initialize 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