Mercurial > vim
comparison src/testdir/test_conceal.vim @ 34559:ef55fe2ac8be v9.1.0180
patch 9.1.0180: Cursor pos wrong when double-width chars are concealed
Commit: https://github.com/vim/vim/commit/010e1539d67442cc69a97bef6453efaf849d0db3
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu Mar 14 18:22:17 2024 +0100
patch 9.1.0180: Cursor pos wrong when double-width chars are concealed
Problem: Cursor pos wrong when double-width chars are concealed.
Solution: Advance one more virtual column for a double-width char.
Run some tests with both 'wrap' and 'nowrap' (zeertzjq).
closes: #14197
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 14 Mar 2024 18:30:05 +0100 |
parents | 4d8d41b7a8eb |
children | fdd232ab72ea |
comparison
equal
deleted
inserted
replaced
34558:4fcffe60b441 | 34559:ef55fe2ac8be |
---|---|
439 call assert_equal([0, 1, 20, 0, 20], getcurpos()) | 439 call assert_equal([0, 1, 20, 0, 20], getcurpos()) |
440 " click on 'e' of "here" puts cursor there | 440 " click on 'e' of "here" puts cursor there |
441 call test_setmouse(1, 19) | 441 call test_setmouse(1, 19) |
442 call feedkeys("\<LeftMouse>", "tx") | 442 call feedkeys("\<LeftMouse>", "tx") |
443 call assert_equal([0, 1, 23, 0, 23], getcurpos()) | 443 call assert_equal([0, 1, 23, 0, 23], getcurpos()) |
444 " click after end of line puts cursor there without 'virtualedit' | 444 " click after end of line puts cursor there with 'virtualedit' |
445 call test_setmouse(1, 20) | 445 call test_setmouse(1, 20) |
446 call feedkeys("\<LeftMouse>", "tx") | 446 call feedkeys("\<LeftMouse>", "tx") |
447 call assert_equal([0, 1, 24, 0, 24], getcurpos()) | 447 call assert_equal([0, 1, 24, 0, 24], getcurpos()) |
448 call test_setmouse(1, 21) | 448 call test_setmouse(1, 21) |
449 call feedkeys("\<LeftMouse>", "tx") | 449 call feedkeys("\<LeftMouse>", "tx") |
462 set mouse& virtualedit& | 462 set mouse& virtualedit& |
463 endfunc | 463 endfunc |
464 | 464 |
465 " Test that cursor is drawn at the correct column when it is after end of the | 465 " Test that cursor is drawn at the correct column when it is after end of the |
466 " line with 'virtualedit' and concealing. | 466 " line with 'virtualedit' and concealing. |
467 func Test_conceal_virtualedit_after_eol() | 467 func Run_test_conceal_virtualedit_after_eol(wrap) |
468 CheckScreendump | 468 let code =<< trim eval [CODE] |
469 | 469 let &wrap = {a:wrap} |
470 let code =<< trim [CODE] | |
471 call setline(1, 'abcdefgh|hidden|ijklmnpop') | 470 call setline(1, 'abcdefgh|hidden|ijklmnpop') |
472 syntax match test /|hidden|/ conceal | 471 syntax match test /|hidden|/ conceal |
473 set conceallevel=2 concealcursor=n virtualedit=all | 472 set conceallevel=2 concealcursor=n virtualedit=all |
474 normal! $ | 473 normal! $ |
475 [CODE] | 474 [CODE] |
487 | 486 |
488 " clean up | 487 " clean up |
489 call StopVimInTerminal(buf) | 488 call StopVimInTerminal(buf) |
490 endfunc | 489 endfunc |
491 | 490 |
492 " Same as Test_conceal_virtualedit_after_eol(), but with 'rightleft' set. | 491 func Test_conceal_virtualedit_after_eol() |
493 func Test_conceal_virtualedit_after_eol_rightleft() | 492 CheckScreendump |
494 CheckFeature rightleft | 493 |
495 CheckScreendump | 494 call Run_test_conceal_virtualedit_after_eol(1) |
496 | 495 call Run_test_conceal_virtualedit_after_eol(0) |
497 let code =<< trim [CODE] | 496 endfunc |
497 | |
498 " Same as Run_test_conceal_virtualedit_after_eol(), but with 'rightleft'. | |
499 func Run_test_conceal_virtualedit_after_eol_rightleft(wrap) | |
500 let code =<< trim eval [CODE] | |
501 let &wrap = {a:wrap} | |
498 call setline(1, 'abcdefgh|hidden|ijklmnpop') | 502 call setline(1, 'abcdefgh|hidden|ijklmnpop') |
499 syntax match test /|hidden|/ conceal | 503 syntax match test /|hidden|/ conceal |
500 set conceallevel=2 concealcursor=n virtualedit=all rightleft | 504 set conceallevel=2 concealcursor=n virtualedit=all rightleft |
501 normal! $ | 505 normal! $ |
502 [CODE] | 506 [CODE] |
514 | 518 |
515 " clean up | 519 " clean up |
516 call StopVimInTerminal(buf) | 520 call StopVimInTerminal(buf) |
517 endfunc | 521 endfunc |
518 | 522 |
523 func Test_conceal_virtualedit_after_eol_rightleft() | |
524 CheckFeature rightleft | |
525 CheckScreendump | |
526 | |
527 call Run_test_conceal_virtualedit_after_eol_rightleft(1) | |
528 call Run_test_conceal_virtualedit_after_eol_rightleft(0) | |
529 endfunc | |
530 | |
531 " Test that cursor position is correct when double-width chars are concealed. | |
532 func Run_test_conceal_double_width(wrap) | |
533 let code =<< trim eval [CODE] | |
534 let &wrap = {a:wrap} | |
535 call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar']) | |
536 syntax match test /口=口/ conceal cchar=β | |
537 set conceallevel=2 concealcursor=n colorcolumn=30 | |
538 normal! $ | |
539 [CODE] | |
540 call writefile(code, 'XTest_conceal_double_width', 'D') | |
541 let buf = RunVimInTerminal('-S XTest_conceal_double_width', {'rows': 4}) | |
542 call VerifyScreenDump(buf, 'Test_conceal_double_width_1', {}) | |
543 call term_sendkeys(buf, "gM") | |
544 call VerifyScreenDump(buf, 'Test_conceal_double_width_2', {}) | |
545 call term_sendkeys(buf, ":set conceallevel=3\<CR>") | |
546 call VerifyScreenDump(buf, 'Test_conceal_double_width_3', {}) | |
547 call term_sendkeys(buf, "$") | |
548 call VerifyScreenDump(buf, 'Test_conceal_double_width_4', {}) | |
549 | |
550 " clean up | |
551 call StopVimInTerminal(buf) | |
552 endfunc | |
553 | |
554 func Test_conceal_double_width() | |
555 CheckScreendump | |
556 | |
557 call Run_test_conceal_double_width(1) | |
558 call Run_test_conceal_double_width(0) | |
559 endfunc | |
560 | |
561 " Test that line wrapping is correct when double-width chars are concealed. | |
562 func Test_conceal_double_width_wrap() | |
563 CheckScreendump | |
564 | |
565 let code =<< trim [CODE] | |
566 call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc') | |
567 syntax match test /口=口/ conceal cchar=β | |
568 set conceallevel=2 concealcursor=n | |
569 normal! $ | |
570 [CODE] | |
571 call writefile(code, 'XTest_conceal_double_width_wrap', 'D') | |
572 let buf = RunVimInTerminal('-S XTest_conceal_double_width_wrap', {'rows': 4, 'cols': 20}) | |
573 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_1', {}) | |
574 call term_sendkeys(buf, "gM") | |
575 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_2', {}) | |
576 call term_sendkeys(buf, ":set conceallevel=3\<CR>") | |
577 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_3', {}) | |
578 call term_sendkeys(buf, "$") | |
579 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_4', {}) | |
580 | |
581 " clean up | |
582 call StopVimInTerminal(buf) | |
583 endfunc | |
584 | |
519 " vim: shiftwidth=2 sts=2 expandtab | 585 " vim: shiftwidth=2 sts=2 expandtab |