aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-07 06:32:54 +0800
committerGitHub <noreply@github.com>2024-07-07 06:32:54 +0800
commit5da9b49b19240bb00f338249fef84a2bf1212b49 (patch)
tree07a864275674601b81c5f77927b7f2b8794d8186 /test
parent7a54d707fa6f32822b241140b31a348ad5ad0e6b (diff)
downloadrneovim-5da9b49b19240bb00f338249fef84a2bf1212b49.tar.gz
rneovim-5da9b49b19240bb00f338249fef84a2bf1212b49.tar.bz2
rneovim-5da9b49b19240bb00f338249fef84a2bf1212b49.zip
vim-patch:9.1.0537: signed number detection for CTRL-X/A can be improved (#29590)
Problem: signed number detection for CTRL-X/A can be improved (Chris Patuzzo) Solution: Add the new "blank" value for the 'nrformat' setting. This will make Vim assume a signed number only if there is a blank in front of the sign. (distobs) fixes: vim/vim#15033 closes: vim/vim#15110 https://github.com/vim/vim/commit/25ac6d67d92e0adda53b8d44b81c15031643ca1e Co-authored-by: distobs <cuppotatocake@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_increment.vim38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/old/testdir/test_increment.vim b/test/old/testdir/test_increment.vim
index 433b2b4471..cf6334747a 100644
--- a/test/old/testdir/test_increment.vim
+++ b/test/old/testdir/test_increment.vim
@@ -841,6 +841,44 @@ func Test_increment_unsigned()
set nrformats-=unsigned
endfunc
+" Try incrementing/decrementing a number when nrformats contains blank
+func Test_increment_blank()
+ set nrformats+=blank
+
+ " Signed
+ call setline(1, '0')
+ exec "norm! gg0\<C-X>"
+ call assert_equal('-1', getline(1))
+
+ call setline(1, '3')
+ exec "norm! gg010\<C-X>"
+ call assert_equal('-7', getline(1))
+
+ call setline(1, '-0')
+ exec "norm! gg0\<C-X>"
+ call assert_equal("-1", getline(1))
+
+ " Unsigned
+ " NOTE: 18446744073709551615 == 2^64 - 1
+ call setline(1, 'a-18446744073709551615')
+ exec "norm! gg0\<C-A>"
+ call assert_equal('a-18446744073709551615', getline(1))
+
+ call setline(1, 'a-18446744073709551615')
+ exec "norm! gg0\<C-A>"
+ call assert_equal('a-18446744073709551615', getline(1))
+
+ call setline(1, 'a-18446744073709551614')
+ exec "norm! gg08\<C-A>"
+ call assert_equal('a-18446744073709551615', getline(1))
+
+ call setline(1, 'a-1')
+ exec "norm! gg0\<C-A>"
+ call assert_equal('a-2', getline(1))
+
+ set nrformats-=blank
+endfunc
+
func Test_in_decrement_large_number()
" NOTE: 18446744073709551616 == 2^64
call setline(1, '18446744073709551616')