patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Problem: 'virtualedit' local to buffer is not the best solution.
Solution: Make it window-local. (Gary Johnson, closes #8685)
diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim
index f3cc260..b31f3a2 100644
--- a/src/testdir/test_virtualedit.vim
+++ b/src/testdir/test_virtualedit.vim
@@ -407,7 +407,7 @@
let s:result_ve_on = 'a x'
let s:result_ve_off = 'x'
-" Utility function for Test_global_local()
+" Utility function for Test_global_local_virtualedit()
func s:TryVirtualeditReplace()
call setline(1, 'a')
normal gg7l
@@ -415,7 +415,7 @@
endfunc
" Test for :set and :setlocal
-func Test_global_local()
+func Test_global_local_virtualedit()
new
" Verify that 'virtualedit' is initialized to empty, can be set globally to
@@ -435,8 +435,8 @@
call s:TryVirtualeditReplace()
call assert_equal(s:result_ve_off, getline(1))
- " Verify that :set affects multiple buffers
- new
+ " Verify that :set affects multiple windows.
+ split
set ve=all
call s:TryVirtualeditReplace()
call assert_equal(s:result_ve_on, getline(1))
@@ -449,17 +449,15 @@
call assert_equal(s:result_ve_off, getline(1))
bwipe!
- " Verify that :setlocal affects only the current buffer
- setlocal ve=all
+ " Verify that :setlocal affects only the current window.
new
- call s:TryVirtualeditReplace()
- call assert_equal(s:result_ve_off, getline(1))
+ split
setlocal ve=all
- wincmd p
- setlocal ve=
- wincmd p
call s:TryVirtualeditReplace()
call assert_equal(s:result_ve_on, getline(1))
+ wincmd p
+ call s:TryVirtualeditReplace()
+ call assert_equal(s:result_ve_off, getline(1))
bwipe!
call s:TryVirtualeditReplace()
call assert_equal(s:result_ve_off, getline(1))
@@ -518,6 +516,23 @@
bwipe!
+ " Verify that the 'virtualedit' state is copied to new windows.
+ new
+ call s:TryVirtualeditReplace()
+ call assert_equal(s:result_ve_off, getline(1))
+ split
+ setlocal ve=all
+ call s:TryVirtualeditReplace()
+ call assert_equal(s:result_ve_on, getline(1))
+ split
+ call s:TryVirtualeditReplace()
+ call assert_equal(s:result_ve_on, getline(1))
+ setlocal ve=
+ split
+ call s:TryVirtualeditReplace()
+ call assert_equal(s:result_ve_off, getline(1))
+ bwipe!
+
setlocal virtualedit&
set virtualedit&
endfunc