diff options
author | ZyX <kp-pav@yandex.ru> | 2015-08-16 01:16:24 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2015-10-08 22:00:46 +0300 |
commit | be45e750267a7cb52b625b2e1e71796be18d8061 (patch) | |
tree | c81e55e7232173fce625ab65b6c21f1984df2fc7 | |
parent | e2c3ea44451fe7b6c67bee78387073fa033e4c0e (diff) | |
download | rneovim-be45e750267a7cb52b625b2e1e71796be18d8061.tar.gz rneovim-be45e750267a7cb52b625b2e1e71796be18d8061.tar.bz2 rneovim-be45e750267a7cb52b625b2e1e71796be18d8061.zip |
shada: Refuse to write ShaDa file when ShaDa was disabled
-rw-r--r-- | src/nvim/shada.c | 4 | ||||
-rw-r--r-- | test/functional/shada/shada_spec.lua | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 1d4b486823..b5e60d0c08 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2895,6 +2895,10 @@ shada_write_exit: /// @return OK if writing was successfull, FAIL otherwise. int shada_write_file(const char *const file, bool nomerge) { + if (shada_disabled()) { + return FAIL; + } + char *const fname = shada_filename(file); char *tempname = NULL; ShaDaWriteDef sd_writer = (ShaDaWriteDef) { diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index 19b8a47244..e256173611 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -3,7 +3,8 @@ local helpers = require('test.functional.helpers') local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq = helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed, 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 msgpack = require('MessagePack') @@ -127,4 +128,22 @@ describe('ShaDa support code', function() end eq(#mpack, found) 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) |