mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
shada: Refuse to write ShaDa file when ShaDa was disabled
This commit is contained in:
parent
e2c3ea4445
commit
be45e75026
@ -2895,6 +2895,10 @@ shada_write_exit:
|
|||||||
/// @return OK if writing was successfull, FAIL otherwise.
|
/// @return OK if writing was successfull, FAIL otherwise.
|
||||||
int shada_write_file(const char *const file, bool nomerge)
|
int shada_write_file(const char *const file, bool nomerge)
|
||||||
{
|
{
|
||||||
|
if (shada_disabled()) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
char *const fname = shada_filename(file);
|
char *const fname = shada_filename(file);
|
||||||
char *tempname = NULL;
|
char *tempname = NULL;
|
||||||
ShaDaWriteDef sd_writer = (ShaDaWriteDef) {
|
ShaDaWriteDef sd_writer = (ShaDaWriteDef) {
|
||||||
|
@ -3,7 +3,8 @@ local helpers = require('test.functional.helpers')
|
|||||||
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
|
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
|
||||||
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
|
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
|
||||||
helpers.eval, helpers.eq
|
helpers.eval, helpers.eq
|
||||||
local write_file = helpers.write_file
|
local write_file, spawn, set_session, nvim_prog =
|
||||||
|
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog
|
||||||
local lfs = require('lfs')
|
local lfs = require('lfs')
|
||||||
|
|
||||||
local msgpack = require('MessagePack')
|
local msgpack = require('MessagePack')
|
||||||
@ -127,4 +128,22 @@ describe('ShaDa support code', function()
|
|||||||
end
|
end
|
||||||
eq(#mpack, found)
|
eq(#mpack, found)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('does not write NONE file', function()
|
||||||
|
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
|
||||||
|
'--cmd', 'qall'}, true)
|
||||||
|
session:exit(0)
|
||||||
|
eq(nil, lfs.attributes('NONE'))
|
||||||
|
eq(nil, lfs.attributes('NONE.tmp.a'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('does not read NONE file', function()
|
||||||
|
write_file('NONE', '\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
|
||||||
|
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed'},
|
||||||
|
true)
|
||||||
|
set_session(session)
|
||||||
|
eq('', nvim_eval('@a'))
|
||||||
|
session:exit(0)
|
||||||
|
os.remove('NONE')
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user