aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-05-18 12:09:22 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-05-18 12:11:11 -0400
commit3574126b89b7162136e57a33fa5efccebefdaf37 (patch)
tree42ad056fde3f508f38f1ec77fddb8c4705bcf598 /src
parente8beea204bf428df3e417a67c151b3a32768befc (diff)
downloadrneovim-3574126b89b7162136e57a33fa5efccebefdaf37.tar.gz
rneovim-3574126b89b7162136e57a33fa5efccebefdaf37.tar.bz2
rneovim-3574126b89b7162136e57a33fa5efccebefdaf37.zip
vim-patch:8.1.1345: stuck in sandbox with ":s/../\=Function/gn"
Problem: Stuck in sandbox with ":s/../\=Function/gn". Solution: Don't skip over code to restore sandbox. (Christian Brabandt) https://github.com/vim/vim/commit/6349e9411fd17f80c7aff9c678a8800647d34cfa
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c7
-rw-r--r--src/nvim/testdir/test_substitute.vim11
2 files changed, 12 insertions, 6 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 560f4e5df2..8436ac810e 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3819,7 +3819,6 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
if (!preview || has_second_delim) {
if (subflags.do_count) {
// prevent accidentally changing the buffer by a function
- save_ma = curbuf->b_p_ma;
curbuf->b_p_ma = false;
sandbox++;
}
@@ -3832,13 +3831,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
sub, sub_firstline, false, p_magic, true);
// If getting the substitute string caused an error, don't do
// the replacement.
- if (aborting()) {
- goto skip;
- }
-
// Don't keep flags set by a recursive call
subflags = subflags_save;
- if (subflags.do_count) {
+ if (aborting() || subflags.do_count) {
curbuf->b_p_ma = save_ma;
if (sandbox > 0) {
sandbox--;
diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim
index e074a85530..8b306192f0 100644
--- a/src/nvim/testdir/test_substitute.vim
+++ b/src/nvim/testdir/test_substitute.vim
@@ -639,6 +639,17 @@ func Test_nocatch_sub_failure_handling()
call assert_equal(1, error_caught)
call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+ " Same, but using "n" flag so that "sandbox" gets set
+ call setline(1, ['1 aaa', '2 aaa', '3 aaa'])
+ let error_caught = 0
+ try
+ %s/aaa/\=Foo()/gn
+ catch
+ let error_caught = 1
+ endtry
+ call assert_equal(1, error_caught)
+ call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+
bwipe!
endfunc