patch 7.4.1857
Problem: When a channel appends to a buffer that is 'nomodifiable' there is
an error but appending is done anyway.
Solution: Add the 'modifiable' option. Refuse to write to a 'nomodifiable'
when the value is 1.
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 363b5cd..ed3fa6d 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -676,7 +676,7 @@
endtry
endfunc
-func Run_test_pipe_to_buffer(use_name)
+func Run_test_pipe_to_buffer(use_name, nomod)
if !has('job')
return
endif
@@ -691,6 +691,9 @@
quit
let firstline = ''
endif
+ if a:nomod
+ let options['out_modifiable'] = 0
+ endif
let job = job_start(s:python . " test_channel_pipe.py", options)
call assert_equal("run", job_status(job))
try
@@ -705,6 +708,11 @@
$del
endif
call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this', 'Goodbye!'], getline(1, '$'))
+ if a:nomod
+ call assert_equal(0, &modifiable)
+ else
+ call assert_equal(1, &modifiable)
+ endif
bwipe!
finally
call job_stop(job)
@@ -712,14 +720,18 @@
endfunc
func Test_pipe_to_buffer_name()
- call Run_test_pipe_to_buffer(1)
+ call Run_test_pipe_to_buffer(1, 0)
endfunc
func Test_pipe_to_buffer_nr()
- call Run_test_pipe_to_buffer(0)
+ call Run_test_pipe_to_buffer(0, 0)
endfunc
-func Run_test_pipe_err_to_buffer(use_name)
+func Test_pipe_to_buffer_name_nomod()
+ call Run_test_pipe_to_buffer(1, 1)
+endfunc
+
+func Run_test_pipe_err_to_buffer(use_name, nomod)
if !has('job')
return
endif
@@ -734,6 +746,9 @@
quit
let firstline = ''
endif
+ if a:nomod
+ let options['err_modifiable'] = 0
+ endif
let job = job_start(s:python . " test_channel_pipe.py", options)
call assert_equal("run", job_status(job))
try
@@ -745,6 +760,11 @@
sp pipe-err
call s:waitFor('line("$") >= 5')
call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this'], getline(1, '$'))
+ if a:nomod
+ call assert_equal(0, &modifiable)
+ else
+ call assert_equal(1, &modifiable)
+ endif
bwipe!
finally
call job_stop(job)
@@ -752,11 +772,15 @@
endfunc
func Test_pipe_err_to_buffer_name()
- call Run_test_pipe_err_to_buffer(1)
+ call Run_test_pipe_err_to_buffer(1, 0)
endfunc
func Test_pipe_err_to_buffer_nr()
- call Run_test_pipe_err_to_buffer(0)
+ call Run_test_pipe_err_to_buffer(0, 0)
+endfunc
+
+func Test_pipe_err_to_buffer_name_nomod()
+ call Run_test_pipe_err_to_buffer(1, 1)
endfunc
func Test_pipe_both_to_buffer()