aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-01-21 11:27:17 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-01-21 18:42:45 +0100
commit154822933ee29f7b27157ff6e5138d8126cfc27f (patch)
treef53d5f44ff622fe6ee98cdf47b20f390697dcfa9 /src
parenta5d33d5e904d217d84171d7edcbb640cca73303a (diff)
downloadrneovim-154822933ee29f7b27157ff6e5138d8126cfc27f.tar.gz
rneovim-154822933ee29f7b27157ff6e5138d8126cfc27f.tar.bz2
rneovim-154822933ee29f7b27157ff6e5138d8126cfc27f.zip
vim-patch:8.0.0659: no test for conceal mode
Problem: No test for conceal mode. Solution: Add a conceal mode test. (Dominique Pelle, closes vim/vim#1783) https://github.com/vim/vim/commit/4d785895d1f8b54cdd3fabd87446ca692f49e94e
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/testdir/test_syntax.vim45
2 files changed, 47 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 48525c2891..f663d13c55 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -16274,8 +16274,8 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// get the conceal character
if ((syntax_flags & HL_CONCEAL) && curwin->w_p_cole < 3) {
cchar = syn_get_sub_char();
- if (cchar == NUL && curwin->w_p_cole == 1 && lcs_conceal != NUL) {
- cchar = lcs_conceal;
+ if (cchar == NUL && curwin->w_p_cole == 1) {
+ cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal;
}
if (cchar != NUL) {
utf_char2bytes(cchar, str);
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 6456ca2b23..21af5d1972 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -1,5 +1,7 @@
" Test for syntax and syntax iskeyword option
+source view_util.vim
+
func GetSyntaxItem(pat)
let c = ''
let a = ['a', getreg('a'), getregtype('a')]
@@ -340,3 +342,46 @@ func Test_invalid_name()
hi clear Nop
hi clear @Wrong
endfunc
+
+
+func Test_conceal()
+ if !has('conceal')
+ return
+ endif
+
+ new
+ call setline(1, ['', '123456'])
+ syn match test23 "23" conceal cchar=X
+ syn match test45 "45" conceal
+
+ set conceallevel=0
+ call assert_equal('123456 ', ScreenLines(2, 7)[0])
+ call assert_equal([[0, ''], [0, ''], [0, ''], [0, ''], [0, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
+
+ set conceallevel=1
+ call assert_equal('1X 6 ', ScreenLines(2, 7)[0])
+ " FIXME: with conceallevel=1, I would expect that the portion "45" of
+ " the line to be replaced with a space since ":help 'conceallevel'
+ " states that if listchars is not set, then the default replacement
+ " should be a space. But synconcealed() gives an empty string in
+ " the 2nd value of the returned list. Bug?
+ " So for now, the following line is commented out:
+ call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ' '], [1, ' '], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
+
+ set conceallevel=1
+ set listchars=conceal:Y
+ call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, 'Y'], [1, 'Y'], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
+ call assert_equal('1XY6 ', ScreenLines(2, 7)[0])
+
+ set conceallevel=2
+ call assert_match('1X6 ', ScreenLines(2, 7)[0])
+ call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ''], [1, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
+
+ set conceallevel=3
+ call assert_match('16 ', ScreenLines(2, 7)[0])
+ call assert_equal([[0, ''], [1, ''], [1, ''], [1, ''], [1, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
+
+ syn clear
+ set conceallevel&
+ bw!
+endfunc