Mercurial > vim
comparison src/testdir/test_syntax.vim @ 23043:6616bf17dc94 v8.2.2068
patch 8.2.2068: transparent syntax item uses start/end of containing region
Commit: https://github.com/vim/vim/commit/b46f57e87b3706a8c4b97d8e03f7853a7938b061
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 29 14:11:41 2020 +0100
patch 8.2.2068: transparent syntax item uses start/end of containing region
Problem: Transparent syntax item uses start/end of containing region.
Solution: Do not change the startpos and endpos of a transparent region to
that of its containing region. (Adrian Ghizaru, closes #7349,
closes #7391)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 29 Nov 2020 14:15:05 +0100 |
parents | de6c242ec236 |
children | d16a69f718b5 |
comparison
equal
deleted
inserted
replaced
23042:c720ff60017a | 23043:6616bf17dc94 |
---|---|
23 norm! l | 23 norm! l |
24 endw | 24 endw |
25 call call('setreg', a) | 25 call call('setreg', a) |
26 0 | 26 0 |
27 return c | 27 return c |
28 endfunc | |
29 | |
30 func AssertHighlightGroups(lnum, startcol, expected, trans = 1, msg = "") | |
31 " Assert that the characters starting at a given (line, col) | |
32 " sequentially match the expected highlight groups. | |
33 " If groups are provided as a string, each character is assumed to be a | |
34 " group and spaces represent no group, useful for visually describing tests. | |
35 let l:expectedGroups = type(a:expected) == v:t_string | |
36 \ ? a:expected->split('\zs')->map({_, v -> trim(v)}) | |
37 \ : a:expected | |
38 let l:errors = 0 | |
39 let l:msg = (a:msg->empty() ? "" : a:msg .. ": ") | |
40 \ .. "Wrong highlight group at " .. a:lnum .. "," | |
41 | |
42 for l:i in range(a:startcol, a:startcol + l:expectedGroups->len() - 1) | |
43 let l:errors += synID(a:lnum, l:i, a:trans) | |
44 \ ->synIDattr("name") | |
45 \ ->assert_equal(l:expectedGroups[l:i - 1], | |
46 \ l:msg .. l:i) | |
47 endfor | |
28 endfunc | 48 endfunc |
29 | 49 |
30 func Test_syn_iskeyword() | 50 func Test_syn_iskeyword() |
31 new | 51 new |
32 call setline(1, [ | 52 call setline(1, [ |
822 delfunc InComment | 842 delfunc InComment |
823 delfunc InString | 843 delfunc InString |
824 bwipe! | 844 bwipe! |
825 endfunc | 845 endfunc |
826 | 846 |
847 func Test_syn_contained_transparent() | |
848 " Comments starting with "Regression:" show the result when the highlighting | |
849 " span of the containing item is assigned to the contained region. | |
850 syntax on | |
851 | |
852 let l:case = "Transparent region contained in region" | |
853 new | |
854 syntax region X start=/\[/ end=/\]/ contained transparent | |
855 syntax region Y start=/(/ end=/)/ contains=X | |
856 | |
857 call setline(1, "==(--[~~]--)==") | |
858 let l:expected = " YYYYYYYYYY " | |
859 eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) | |
860 syntax clear Y X | |
861 bw! | |
862 | |
863 let l:case = "Transparent region extends region" | |
864 new | |
865 syntax region X start=/\[/ end=/\]/ contained transparent | |
866 syntax region Y start=/(/ end=/)/ end=/e/ contains=X | |
867 | |
868 call setline(1, "==(--[~~e~~]--)==") | |
869 let l:expected = " YYYYYYYYYYYYY " | |
870 " Regression: " YYYYYYY YYY " | |
871 eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) | |
872 syntax clear Y X | |
873 bw! | |
874 | |
875 let l:case = "Nested transparent regions extend region" | |
876 new | |
877 syntax region X start=/\[/ end=/\]/ contained transparent | |
878 syntax region Y start=/(/ end=/)/ end=/e/ contains=X | |
879 | |
880 call setline(1, "==(--[~~e~~[~~e~~]~~e~~]--)==") | |
881 let l:expected = " YYYYYYYYYYYYYYYYYYYYYYYYY " | |
882 " Regression: " YYYYYYY YYYYYYYYY " | |
883 eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) | |
884 syntax clear Y X | |
885 bw! | |
886 | |
887 let l:case = "Transparent region contained in match" | |
888 new | |
889 syntax region X start=/\[/ end=/\]/ contained transparent | |
890 syntax match Y /(.\{-})/ contains=X | |
891 | |
892 call setline(1, "==(--[~~]--)==") | |
893 let l:expected = " YYYYYYYYYY " | |
894 eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) | |
895 syntax clear Y X | |
896 bw! | |
897 | |
898 let l:case = "Transparent region extends match" | |
899 new | |
900 syntax region X start=/\[/ end=/\]/ contained transparent | |
901 syntax match Y /(.\{-}[e)]/ contains=X | |
902 | |
903 call setline(1, "==(--[~~e~~]--)==") | |
904 let l:expected = " YYYYYYYYYY " | |
905 " Regression: " YYYYYYY " | |
906 eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) | |
907 syntax clear Y X | |
908 bw! | |
909 | |
910 let l:case = "Nested transparent regions extend match" | |
911 new | |
912 syntax region X start=/\[/ end=/\]/ contained transparent | |
913 syntax match Y /(.\{-}[e)]/ contains=X | |
914 | |
915 call setline(1, "==(--[~~e~~[~~e~~]~~e~~]--)==") | |
916 let l:expected = " YYYYYYYYYYYYYYYYYYYYYY " | |
917 " Regression: " YYYYYYY YYYYYY " | |
918 eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) | |
919 syntax clear Y X | |
920 bw! | |
921 endfunc | |
922 | |
827 " vim: shiftwidth=2 sts=2 expandtab | 923 " vim: shiftwidth=2 sts=2 expandtab |