Mercurial > vim
comparison src/testdir/test_registers.vim @ 20891:4bdc07beeadb v8.2.0997
patch 8.2.0997: cannot execute a register containing line continuation
Commit: https://github.com/vim/vim/commit/856c1110c1cf0d6e44e387b70732ca4b4c8ef0f2
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 17 21:47:23 2020 +0200
patch 8.2.0997: cannot execute a register containing line continuation
Problem: Cannot execute a register containing line continuation.
Solution: Concatenate lines where needed. (Yegappan Lakshmanan,
closes #6272)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 17 Jun 2020 22:00:05 +0200 |
parents | e6a5a5ef4034 |
children | 1c36b96522ae |
comparison
equal
deleted
inserted
replaced
20890:2ac788c89015 | 20891:4bdc07beeadb |
---|---|
555 | 555 |
556 set opfunc& | 556 set opfunc& |
557 bwipe! | 557 bwipe! |
558 endfunc | 558 endfunc |
559 | 559 |
560 " Test for executing the contents of a register as an Ex command with line | |
561 " continuation. | |
562 func Test_execute_reg_as_ex_cmd() | |
563 " Line continuation with just two lines | |
564 let code =<< trim END | |
565 let l = [ | |
566 \ 1] | |
567 END | |
568 let @r = code->join("\n") | |
569 let l = [] | |
570 @r | |
571 call assert_equal([1], l) | |
572 | |
573 " Line continuation with more than two lines | |
574 let code =<< trim END | |
575 let l = [ | |
576 \ 1, | |
577 \ 2, | |
578 \ 3] | |
579 END | |
580 let @r = code->join("\n") | |
581 let l = [] | |
582 @r | |
583 call assert_equal([1, 2, 3], l) | |
584 | |
585 " use comments interspersed with code | |
586 let code =<< trim END | |
587 let l = [ | |
588 "\ one | |
589 \ 1, | |
590 "\ two | |
591 \ 2, | |
592 "\ three | |
593 \ 3] | |
594 END | |
595 let @r = code->join("\n") | |
596 let l = [] | |
597 @r | |
598 call assert_equal([1, 2, 3], l) | |
599 | |
600 " use line continuation in the middle | |
601 let code =<< trim END | |
602 let a = "one" | |
603 let l = [ | |
604 \ 1, | |
605 \ 2] | |
606 let b = "two" | |
607 END | |
608 let @r = code->join("\n") | |
609 let l = [] | |
610 @r | |
611 call assert_equal([1, 2], l) | |
612 call assert_equal("one", a) | |
613 call assert_equal("two", b) | |
614 | |
615 " only one line with a \ | |
616 let @r = "\\let l = 1" | |
617 call assert_fails('@r', 'E10:') | |
618 | |
619 " only one line with a "\ | |
620 let @r = ' "\ let i = 1' | |
621 @r | |
622 call assert_false(exists('i')) | |
623 | |
624 " first line also begins with a \ | |
625 let @r = "\\let l = [\n\\ 1]" | |
626 call assert_fails('@r', 'E10:') | |
627 | |
628 " Test with a large number of lines | |
629 let @r = "let str = \n" | |
630 let @r ..= repeat(" \\ 'abcdefghijklmnopqrstuvwxyz' ..\n", 312) | |
631 let @r ..= ' \ ""' | |
632 @r | |
633 call assert_equal(repeat('abcdefghijklmnopqrstuvwxyz', 312), str) | |
634 endfunc | |
635 | |
560 " vim: shiftwidth=2 sts=2 expandtab | 636 " vim: shiftwidth=2 sts=2 expandtab |