Skip to content

Commit 80627cf

Browse files
committed
patch 8.0.0263: Farsi support is not tested enough
Problem: Farsi support is not tested enough. Solution: Add more tests for Farsi. Clean up the code.
1 parent ddf662a commit 80627cf

3 files changed

Lines changed: 88 additions & 56 deletions

File tree

src/farsi.c

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,56 +1920,56 @@ cmdl_fkmap(int c)
19201920
case NL:
19211921
case TAB:
19221922

1923-
switch ((tempc = cmd_gchar(AT_CURSOR)))
1924-
{
1925-
case _BE:
1926-
case _PE:
1927-
case _TE:
1928-
case _SE:
1929-
case _JIM:
1930-
case _CHE:
1931-
case _HE_J:
1932-
case _XE:
1933-
case _SIN:
1934-
case _SHIN:
1935-
case _SAD:
1936-
case _ZAD:
1937-
case _AYN:
1938-
case _GHAYN:
1939-
case _FE:
1940-
case _GHAF:
1941-
case _KAF:
1942-
case _GAF:
1943-
case _LAM:
1944-
case _MIM:
1945-
case _NOON:
1946-
case _HE:
1947-
case _HE_:
1948-
cmd_pchar(toF_TyA(tempc), AT_CURSOR);
1949-
break;
1950-
case _AYN_:
1951-
cmd_pchar(AYN_, AT_CURSOR);
1952-
break;
1953-
case _GHAYN_:
1954-
cmd_pchar(GHAYN_, AT_CURSOR);
1955-
break;
1956-
case _IE:
1957-
if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1))
1958-
cmd_pchar(IE_, AT_CURSOR);
1959-
else
1960-
cmd_pchar(IE, AT_CURSOR);
1961-
break;
1962-
case _YEE:
1963-
if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1))
1964-
cmd_pchar(YEE_, AT_CURSOR);
1965-
else
1966-
cmd_pchar(YEE, AT_CURSOR);
1967-
break;
1968-
case _YE:
1969-
if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1))
1970-
cmd_pchar(YE_, AT_CURSOR);
1971-
else
1972-
cmd_pchar(YE, AT_CURSOR);
1923+
switch ((tempc = cmd_gchar(AT_CURSOR)))
1924+
{
1925+
case _BE:
1926+
case _PE:
1927+
case _TE:
1928+
case _SE:
1929+
case _JIM:
1930+
case _CHE:
1931+
case _HE_J:
1932+
case _XE:
1933+
case _SIN:
1934+
case _SHIN:
1935+
case _SAD:
1936+
case _ZAD:
1937+
case _AYN:
1938+
case _GHAYN:
1939+
case _FE:
1940+
case _GHAF:
1941+
case _KAF:
1942+
case _GAF:
1943+
case _LAM:
1944+
case _MIM:
1945+
case _NOON:
1946+
case _HE:
1947+
case _HE_:
1948+
cmd_pchar(toF_TyA(tempc), AT_CURSOR);
1949+
break;
1950+
case _AYN_:
1951+
cmd_pchar(AYN_, AT_CURSOR);
1952+
break;
1953+
case _GHAYN_:
1954+
cmd_pchar(GHAYN_, AT_CURSOR);
1955+
break;
1956+
case _IE:
1957+
if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1))
1958+
cmd_pchar(IE_, AT_CURSOR);
1959+
else
1960+
cmd_pchar(IE, AT_CURSOR);
1961+
break;
1962+
case _YEE:
1963+
if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1))
1964+
cmd_pchar(YEE_, AT_CURSOR);
1965+
else
1966+
cmd_pchar(YEE, AT_CURSOR);
1967+
break;
1968+
case _YE:
1969+
if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1))
1970+
cmd_pchar(YE_, AT_CURSOR);
1971+
else
1972+
cmd_pchar(YE, AT_CURSOR);
19731973
}
19741974

19751975
switch (c)

src/testdir/test_farsi.vim

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,43 @@ func Test_input_farsi()
9191
call feedkeys("aabc0123456789.+-^%#=xyz\<Esc>", 'tx')
9292
call assert_equal("\x8c旽蔭左重此虞項斑盛啪\x93", getline('.'))
9393

94-
" all non-number special chars
95-
call feedkeys("aB E F H I K L M O P Q R T U W Y ` ! @ # $ % ^ & * () - _ = + \\ | : \" . / < > ? \<Esc>", 'tx')
96-
call assert_equal("\x8c旽蔭左重此虞項斑盛啪\x93捸��������貝�����", getline('.'))
94+
" all non-number special chars with spaces
95+
call feedkeys("oB E F H I K L M O P Q R T U W Y ` ! @ # $ % ^ & * () - _ = + \\ | : \" . / < > ? \<Esc>", 'tx')
96+
call assert_equal("��������[��������貝�����", getline('.'))
9797

98-
" all letter chars
99-
call feedkeys("aa A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \ , [ ] \<Esc>", 'tx')
100-
call assert_equal("\x8c旽蔭左重此虞項斑盛啪\x93捸��������貝�������������������������������������������", getline('.'))
98+
" all non-number special chars without spaces
99+
call feedkeys("oBEFHIKLMOPQRTUWY`!@#$%^&*()-_=+\\|:\"./<>?\<Esc>",'tx')
100+
call assert_equal("↑欉褅[]蘼襝蘘╯妙丰狀閮帛朣恨篝誚紋撚", getline('.'))
101+
102+
" all letter chars with spaces
103+
call feedkeys("oa A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \ , [ ] \<Esc>", 'tx')
104+
call assert_equal("��������������������������������������", getline('.'))
105+
106+
" all letter chars without spaces
107+
call feedkeys("oaAbcCdDefgGhijJklmnNopqrsStuvVwxXyzZ;\,[]\<Esc>", 'tx')
108+
call assert_equal("\x8c癵恘\x9f螰x86\x83媱縷x9d\x85\x80\x9c\x9b\x84\x8a\x89\x8e\x96\x8b餤x95\x90\x8d\x93\x97綅x87\x88", getline('.'))
101109

102110
bwipe!
103111
endfunc
112+
113+
func Test_command_line_farsi()
114+
set allowrevins altkeymap
115+
116+
" letter characters with spaces
117+
call feedkeys(":\"\<C-_>a A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \\ , [ ]\<CR>", 'tx')
118+
call assert_equal("\"\x88", getreg(':'))
119+
120+
" letter characters without spaces
121+
call feedkeys(":\"\<C-_>aAbcCdDefgGhijJklmnNopqrsStuvVwxXyzZ;\\,[]\<CR>", 'tx')
122+
call assert_equal("\"\x88\x87蜎祰惝x93娵\x8d\x90\x95餤x8b\x96\x8e\x89\x8a\x84\x9b\x9c\x80\x85\x9d霞鄃x83\x86螰x9f玴泂\x8c", getreg(':'))
123+
124+
" other characters with spaces
125+
call feedkeys(":\"\<C-_>0 1 2 3 4 5 6 7 8 9 ` . ! \" $ % ^ & / () = \\ ? + - _ * : # ~ @ < > { } | B E F H I K L M O P Q R T U W Y\<CR>", 'tx')
126+
call assert_equal("\"������]����岳��", getreg(':'))
127+
128+
" other characters without spaces
129+
call feedkeys(":\"\<C-_>0123456789`.!\"$%^&/()=\\?+-_*:#~@<>{}|BEFHIKLMOPQRTUWY\<CR>", 'tx')
130+
call assert_equal("\"嚬貗齀][釐翫盪禲瞕{撫坍捏鴇重辨蔗辛洩奶誨弛兢毓絕陴掠", getreg(':'))
131+
132+
set noallowrevins noaltkeymap
133+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
263,
767769
/**/
768770
262,
769771
/**/

0 commit comments

Comments
 (0)