mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-patch:8.1.1360: buffer left 'nomodifiable' after :substitute
Problem: Buffer left 'nomodifiable' after :substitute. (Ingo Karkat)
Solution: Save the value of 'modifiable' earlier' (Christian Brabandt,
closes vim/vim#4403)
80341bcd89
This commit is contained in:
@@ -3817,6 +3817,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
|||||||
// 3. Substitute the string. During 'inccommand' preview only do this if
|
// 3. Substitute the string. During 'inccommand' preview only do this if
|
||||||
// there is a replace pattern.
|
// there is a replace pattern.
|
||||||
if (!preview || has_second_delim) {
|
if (!preview || has_second_delim) {
|
||||||
|
save_ma = curbuf->b_p_ma;
|
||||||
if (subflags.do_count) {
|
if (subflags.do_count) {
|
||||||
// prevent accidentally changing the buffer by a function
|
// prevent accidentally changing the buffer by a function
|
||||||
curbuf->b_p_ma = false;
|
curbuf->b_p_ma = false;
|
||||||
|
@@ -612,9 +612,24 @@ func Test_sub_replace_10()
|
|||||||
call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g'))
|
call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_sub_cmd_9()
|
||||||
|
new
|
||||||
|
let input = ['1 aaa', '2 aaa', '3 aaa']
|
||||||
|
call setline(1, input)
|
||||||
|
func Foo()
|
||||||
|
return submatch(0)
|
||||||
|
endfunc
|
||||||
|
%s/aaa/\=Foo()/gn
|
||||||
|
call assert_equal(input, getline(1, '$'))
|
||||||
|
call assert_equal(1, &modifiable)
|
||||||
|
|
||||||
|
delfunc Foo
|
||||||
|
bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_nocatch_sub_failure_handling()
|
func Test_nocatch_sub_failure_handling()
|
||||||
" normal error results in all replacements
|
" normal error results in all replacements
|
||||||
func! Foo()
|
func Foo()
|
||||||
foobar
|
foobar
|
||||||
endfunc
|
endfunc
|
||||||
new
|
new
|
||||||
@@ -650,6 +665,7 @@ func Test_nocatch_sub_failure_handling()
|
|||||||
call assert_equal(1, error_caught)
|
call assert_equal(1, error_caught)
|
||||||
call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
|
call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
|
||||||
|
|
||||||
|
delfunc Foo
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user