diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_diffmode.vim | 31 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c324a9f1a2..66c46e2478 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8008,7 +8008,7 @@ static void f_diff_hlID(typval_T *argvars, typval_T *rettv, FunPtr fptr) hlID = HLF_CHD; // Changed line. } } - rettv->vval.v_number = hlID == (hlf_T)0 ? 0 : (int)hlID; + rettv->vval.v_number = hlID == (hlf_T)0 ? 0 : (int)(hlID + 1); } /* diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index ad3eec3274..b2e75265a6 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -527,7 +527,7 @@ func Test_setting_cursor() new Xtest2 put =range(1,100) wq - + tabe Xtest2 $ diffsp Xtest1 @@ -672,6 +672,35 @@ func Test_diff_filler() %bwipe! endfunc +func Test_diff_hlID() + new + call setline(1, [1, 2, 3]) + diffthis + vnew + call setline(1, ['1x', 2, 'x', 3]) + diffthis + redraw + + call assert_equal(synIDattr(diff_hlID(-1, 1), "name"), "") + + call assert_equal(diff_hlID(1, 1), hlID("DiffChange")) + call assert_equal(synIDattr(diff_hlID(1, 1), "name"), "DiffChange") + call assert_equal(diff_hlID(1, 2), hlID("DiffText")) + call assert_equal(synIDattr(diff_hlID(1, 2), "name"), "DiffText") + call assert_equal(synIDattr(diff_hlID(2, 1), "name"), "") + call assert_equal(diff_hlID(3, 1), hlID("DiffAdd")) + call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "DiffAdd") + call assert_equal(synIDattr(diff_hlID(4, 1), "name"), "") + + wincmd w + call assert_equal(diff_hlID(1, 1), hlID("DiffChange")) + call assert_equal(synIDattr(diff_hlID(1, 1), "name"), "DiffChange") + call assert_equal(synIDattr(diff_hlID(2, 1), "name"), "") + call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "") + + %bwipe! +endfunc + func Test_diff_lastline() enew! only! |