Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 17085:620e9011b685 v8.1.1542
patch 8.1.1542: an OptionSet autocommand does not get enough info
commit https://github.com/vim/vim/commit/d7c968794710f338d491072171df48f96612cf72
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 15 17:12:48 2019 +0200
patch 8.1.1542: an OptionSet autocommand does not get enough info
Problem: An OptionSet autocommand does not get enough info.
Solution: Add v:option_command, v:option_oldlocal and v:option_oldglobal.
(Latrice Wilgus, closes #4118)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Jun 2019 17:15:05 +0200 |
parents | 9c90cf08cfa8 |
children | 5cda6165a5c1 |
comparison
equal
deleted
inserted
replaced
17084:06dcb09b3b07 | 17085:620e9011b685 |
---|---|
493 func Test_empty_doau() | 493 func Test_empty_doau() |
494 doau \| | 494 doau \| |
495 endfunc | 495 endfunc |
496 | 496 |
497 func s:AutoCommandOptionSet(match) | 497 func s:AutoCommandOptionSet(match) |
498 let template = "Option: <%s>, OldVal: <%s>, OldValLocal: <%s>, OldValGlobal: <%s>, NewVal: <%s>, Scope: <%s>, Command: <%s>\n" | |
498 let item = remove(g:options, 0) | 499 let item = remove(g:options, 0) |
499 let expected = printf("Option: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3]) | 500 let expected = printf(template, item[0], item[1], item[2], item[3], item[4], item[5], item[6]) |
500 let actual = printf("Option: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", a:match, v:option_old, v:option_new, v:option_type) | 501 let actual = printf(template, a:match, v:option_old, v:option_oldlocal, v:option_oldglobal, v:option_new, v:option_type, v:option_command) |
501 let g:opt = [expected, actual] | 502 let g:opt = [expected, actual] |
502 "call assert_equal(expected, actual) | 503 "call assert_equal(expected, actual) |
503 endfunc | 504 endfunc |
504 | 505 |
505 func Test_OptionSet() | 506 func Test_OptionSet() |
512 call test_override('starting', 1) | 513 call test_override('starting', 1) |
513 set nocp | 514 set nocp |
514 au OptionSet * :call s:AutoCommandOptionSet(expand("<amatch>")) | 515 au OptionSet * :call s:AutoCommandOptionSet(expand("<amatch>")) |
515 | 516 |
516 " 1: Setting number option" | 517 " 1: Setting number option" |
517 let g:options=[['number', 0, 1, 'global']] | 518 let g:options=[['number', 0, 0, 0, 1, 'global', 'set']] |
518 set nu | 519 set nu |
519 call assert_equal([], g:options) | 520 call assert_equal([], g:options) |
520 call assert_equal(g:opt[0], g:opt[1]) | 521 call assert_equal(g:opt[0], g:opt[1]) |
521 | 522 |
522 " 2: Setting local number option" | 523 " 2: Setting local number option" |
523 let g:options=[['number', 1, 0, 'local']] | 524 let g:options=[['number', 1, 1, '', 0, 'local', 'setlocal']] |
524 setlocal nonu | 525 setlocal nonu |
525 call assert_equal([], g:options) | 526 call assert_equal([], g:options) |
526 call assert_equal(g:opt[0], g:opt[1]) | 527 call assert_equal(g:opt[0], g:opt[1]) |
527 | 528 |
528 " 3: Setting global number option" | 529 " 3: Setting global number option" |
529 let g:options=[['number', 1, 0, 'global']] | 530 let g:options=[['number', 1, '', 1, 0, 'global', 'setglobal']] |
530 setglobal nonu | 531 setglobal nonu |
531 call assert_equal([], g:options) | 532 call assert_equal([], g:options) |
532 call assert_equal(g:opt[0], g:opt[1]) | 533 call assert_equal(g:opt[0], g:opt[1]) |
533 | 534 |
534 " 4: Setting local autoindent option" | 535 " 4: Setting local autoindent option" |
535 let g:options=[['autoindent', 0, 1, 'local']] | 536 let g:options=[['autoindent', 0, 0, '', 1, 'local', 'setlocal']] |
536 setlocal ai | 537 setlocal ai |
537 call assert_equal([], g:options) | 538 call assert_equal([], g:options) |
538 call assert_equal(g:opt[0], g:opt[1]) | 539 call assert_equal(g:opt[0], g:opt[1]) |
539 | 540 |
540 " 5: Setting global autoindent option" | 541 " 5: Setting global autoindent option" |
541 let g:options=[['autoindent', 0, 1, 'global']] | 542 let g:options=[['autoindent', 0, '', 0, 1, 'global', 'setglobal']] |
542 setglobal ai | 543 setglobal ai |
543 call assert_equal([], g:options) | 544 call assert_equal([], g:options) |
544 call assert_equal(g:opt[0], g:opt[1]) | 545 call assert_equal(g:opt[0], g:opt[1]) |
545 | 546 |
546 " 6: Setting global autoindent option" | 547 " 6: Setting global autoindent option" |
547 let g:options=[['autoindent', 1, 0, 'global']] | 548 let g:options=[['autoindent', 1, 1, 1, 0, 'global', 'set']] |
549 set ai! | |
550 call assert_equal([], g:options) | |
551 call assert_equal(g:opt[0], g:opt[1]) | |
552 | |
553 " 6a: Setting global autoindent option" | |
554 let g:options=[['autoindent', 1, 1, 0, 0, 'global', 'set']] | |
555 noa setlocal ai | |
556 noa setglobal noai | |
548 set ai! | 557 set ai! |
549 call assert_equal([], g:options) | 558 call assert_equal([], g:options) |
550 call assert_equal(g:opt[0], g:opt[1]) | 559 call assert_equal(g:opt[0], g:opt[1]) |
551 | 560 |
552 " Should not print anything, use :noa | 561 " Should not print anything, use :noa |
553 " 7: don't trigger OptionSet" | 562 " 7: don't trigger OptionSet" |
554 let g:options=[['invalid', 1, 1, 'invalid']] | 563 let g:options=[['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']] |
555 noa set nonu | 564 noa set nonu |
556 call assert_equal([['invalid', 1, 1, 'invalid']], g:options) | 565 call assert_equal([['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']], g:options) |
557 call assert_equal(g:opt[0], g:opt[1]) | 566 call assert_equal(g:opt[0], g:opt[1]) |
558 | 567 |
559 " 8: Setting several global list and number option" | 568 " 8: Setting several global list and number option" |
560 let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']] | 569 let g:options=[['list', 0, 0, 0, 1, 'global', 'set'], ['number', 0, 0, 0, 1, 'global', 'set']] |
561 set list nu | 570 set list nu |
562 call assert_equal([], g:options) | 571 call assert_equal([], g:options) |
563 call assert_equal(g:opt[0], g:opt[1]) | 572 call assert_equal(g:opt[0], g:opt[1]) |
564 | 573 |
565 " 9: don't trigger OptionSet" | 574 " 9: don't trigger OptionSet" |
566 let g:options=[['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']] | 575 let g:options=[['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid'], ['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']] |
567 noa set nolist nonu | 576 noa set nolist nonu |
568 call assert_equal([['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']], g:options) | 577 call assert_equal([['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid'], ['invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid', 'invalid']], g:options) |
569 call assert_equal(g:opt[0], g:opt[1]) | 578 call assert_equal(g:opt[0], g:opt[1]) |
570 | 579 |
571 " 10: Setting global acd" | 580 " 10: Setting global acd" |
572 let g:options=[['autochdir', 0, 1, 'local']] | 581 let g:options=[['autochdir', 0, 0, '', 1, 'local', 'setlocal']] |
573 setlocal acd | 582 setlocal acd |
574 call assert_equal([], g:options) | 583 call assert_equal([], g:options) |
575 call assert_equal(g:opt[0], g:opt[1]) | 584 call assert_equal(g:opt[0], g:opt[1]) |
576 | 585 |
577 " 11: Setting global autoread (also sets local value)" | 586 " 11: Setting global autoread (also sets local value)" |
578 let g:options=[['autoread', 0, 1, 'global']] | 587 let g:options=[['autoread', 0, 0, 0, 1, 'global', 'set']] |
579 set ar | 588 set ar |
580 call assert_equal([], g:options) | 589 call assert_equal([], g:options) |
581 call assert_equal(g:opt[0], g:opt[1]) | 590 call assert_equal(g:opt[0], g:opt[1]) |
582 | 591 |
583 " 12: Setting local autoread" | 592 " 12: Setting local autoread" |
584 let g:options=[['autoread', 1, 1, 'local']] | 593 let g:options=[['autoread', 1, 1, '', 1, 'local', 'setlocal']] |
585 setlocal ar | 594 setlocal ar |
586 call assert_equal([], g:options) | 595 call assert_equal([], g:options) |
587 call assert_equal(g:opt[0], g:opt[1]) | 596 call assert_equal(g:opt[0], g:opt[1]) |
588 | 597 |
589 " 13: Setting global autoread" | 598 " 13: Setting global autoread" |
590 let g:options=[['autoread', 1, 0, 'global']] | 599 let g:options=[['autoread', 1, '', 1, 0, 'global', 'setglobal']] |
591 setglobal invar | 600 setglobal invar |
592 call assert_equal([], g:options) | 601 call assert_equal([], g:options) |
593 call assert_equal(g:opt[0], g:opt[1]) | 602 call assert_equal(g:opt[0], g:opt[1]) |
594 | 603 |
595 " 14: Setting option backspace through :let" | 604 " 14: Setting option backspace through :let" |
596 let g:options=[['backspace', '', 'eol,indent,start', 'global']] | 605 let g:options=[['backspace', '', '', '', 'eol,indent,start', 'global', 'set']] |
597 let &bs="eol,indent,start" | 606 let &bs="eol,indent,start" |
598 call assert_equal([], g:options) | 607 call assert_equal([], g:options) |
599 call assert_equal(g:opt[0], g:opt[1]) | 608 call assert_equal(g:opt[0], g:opt[1]) |
600 | 609 |
601 " 15: Setting option backspace through setbufvar()" | 610 " 15: Setting option backspace through setbufvar()" |
602 let g:options=[['backup', 0, 1, 'local']] | 611 let g:options=[['backup', 0, 0, '', 1, 'local', 'setlocal']] |
603 " try twice, first time, shouldn't trigger because option name is invalid, | 612 " try twice, first time, shouldn't trigger because option name is invalid, |
604 " second time, it should trigger | 613 " second time, it should trigger |
605 let bnum = bufnr('%') | 614 let bnum = bufnr('%') |
606 call assert_fails("call setbufvar(bnum, '&l:bk', 1)", "E355") | 615 call assert_fails("call setbufvar(bnum, '&l:bk', 1)", "E355") |
607 " should trigger, use correct option name | 616 " should trigger, use correct option name |
608 call setbufvar(bnum, '&backup', 1) | 617 call setbufvar(bnum, '&backup', 1) |
609 call assert_equal([], g:options) | 618 call assert_equal([], g:options) |
610 call assert_equal(g:opt[0], g:opt[1]) | 619 call assert_equal(g:opt[0], g:opt[1]) |
611 | 620 |
612 " 16: Setting number option using setwinvar" | 621 " 16: Setting number option using setwinvar" |
613 let g:options=[['number', 0, 1, 'local']] | 622 let g:options=[['number', 0, 0, '', 1, 'local', 'setlocal']] |
614 call setwinvar(0, '&number', 1) | 623 call setwinvar(0, '&number', 1) |
615 call assert_equal([], g:options) | 624 call assert_equal([], g:options) |
616 call assert_equal(g:opt[0], g:opt[1]) | 625 call assert_equal(g:opt[0], g:opt[1]) |
617 | 626 |
618 " 17: Setting key option, shouldn't trigger" | 627 " 17: Setting key option, shouldn't trigger" |
619 let g:options=[['key', 'invalid', 'invalid1', 'invalid']] | 628 let g:options=[['key', 'invalid', 'invalid1', 'invalid2', 'invalid3', 'invalid4', 'invalid5']] |
620 setlocal key=blah | 629 setlocal key=blah |
621 setlocal key= | 630 setlocal key= |
622 call assert_equal([['key', 'invalid', 'invalid1', 'invalid']], g:options) | 631 call assert_equal([['key', 'invalid', 'invalid1', 'invalid2', 'invalid3', 'invalid4', 'invalid5']], g:options) |
623 call assert_equal(g:opt[0], g:opt[1]) | 632 call assert_equal(g:opt[0], g:opt[1]) |
624 | 633 |
625 " 18: Setting string option" | 634 |
635 " 18a: Setting string global option" | |
636 let oldval = &backupext | |
637 let g:options=[['backupext', oldval, oldval, oldval, 'foo', 'global', 'set']] | |
638 set backupext=foo | |
639 call assert_equal([], g:options) | |
640 call assert_equal(g:opt[0], g:opt[1]) | |
641 | |
642 " 18b: Resetting string global option" | |
643 let g:options=[['backupext', 'foo', 'foo', 'foo', oldval, 'global', 'set']] | |
644 set backupext& | |
645 call assert_equal([], g:options) | |
646 call assert_equal(g:opt[0], g:opt[1]) | |
647 | |
648 " 18c: Setting global string global option" | |
649 let g:options=[['backupext', oldval, '', oldval, 'bar', 'global', 'setglobal']] | |
650 setglobal backupext=bar | |
651 call assert_equal([], g:options) | |
652 call assert_equal(g:opt[0], g:opt[1]) | |
653 | |
654 " 18d: Setting local string global option" | |
655 " As this is a global option this sets the global value even though | |
656 " :setlocal is used! | |
657 noa set backupext& " Reset global and local value (without triggering autocmd) | |
658 let g:options=[['backupext', oldval, oldval, '', 'baz', 'local', 'setlocal']] | |
659 setlocal backupext=baz | |
660 call assert_equal([], g:options) | |
661 call assert_equal(g:opt[0], g:opt[1]) | |
662 | |
663 " 18e: Setting again string global option" | |
664 noa setglobal backupext=ext_global " Reset global and local value (without triggering autocmd) | |
665 noa setlocal backupext=ext_local " Sets the global(!) value! | |
666 let g:options=[['backupext', 'ext_local', 'ext_local', 'ext_local', 'fuu', 'global', 'set']] | |
667 set backupext=fuu | |
668 call assert_equal([], g:options) | |
669 call assert_equal(g:opt[0], g:opt[1]) | |
670 | |
671 | |
672 " 19a: Setting string local-global (to buffer) option" | |
626 let oldval = &tags | 673 let oldval = &tags |
627 let g:options=[['tags', oldval, 'tagpath', 'global']] | 674 let g:options=[['tags', oldval, oldval, oldval, 'tagpath', 'global', 'set']] |
628 set tags=tagpath | 675 set tags=tagpath |
629 call assert_equal([], g:options) | 676 call assert_equal([], g:options) |
630 call assert_equal(g:opt[0], g:opt[1]) | 677 call assert_equal(g:opt[0], g:opt[1]) |
631 | 678 |
632 " 1l: Resetting string option" | 679 " 19b: Resetting string local-global (to buffer) option" |
633 let g:options=[['tags', 'tagpath', oldval, 'global']] | 680 let g:options=[['tags', 'tagpath', 'tagpath', 'tagpath', oldval, 'global', 'set']] |
634 set tags& | 681 set tags& |
635 call assert_equal([], g:options) | 682 call assert_equal([], g:options) |
636 call assert_equal(g:opt[0], g:opt[1]) | 683 call assert_equal(g:opt[0], g:opt[1]) |
684 | |
685 " 19c: Setting global string local-global (to buffer) option " | |
686 let g:options=[['tags', oldval, '', oldval, 'tagpath1', 'global', 'setglobal']] | |
687 setglobal tags=tagpath1 | |
688 call assert_equal([], g:options) | |
689 call assert_equal(g:opt[0], g:opt[1]) | |
690 | |
691 " 19d: Setting local string local-global (to buffer) option" | |
692 let g:options=[['tags', 'tagpath1', 'tagpath1', '', 'tagpath2', 'local', 'setlocal']] | |
693 setlocal tags=tagpath2 | |
694 call assert_equal([], g:options) | |
695 call assert_equal(g:opt[0], g:opt[1]) | |
696 | |
697 " 19e: Setting again string local-global (to buffer) option" | |
698 " Note: v:option_old is the old global value for local-global string options | |
699 " but the old local value for all other kinds of options. | |
700 noa setglobal tags=tag_global " Reset global and local value (without triggering autocmd) | |
701 noa setlocal tags=tag_local | |
702 let g:options=[['tags', 'tag_global', 'tag_local', 'tag_global', 'tagpath', 'global', 'set']] | |
703 set tags=tagpath | |
704 call assert_equal([], g:options) | |
705 call assert_equal(g:opt[0], g:opt[1]) | |
706 | |
707 " 19f: Setting string local-global (to buffer) option to an empty string" | |
708 " Note: v:option_old is the old global value for local-global string options | |
709 " but the old local value for all other kinds of options. | |
710 noa set tags=tag_global " Reset global and local value (without triggering autocmd) | |
711 noa setlocal tags= " empty string | |
712 let g:options=[['tags', 'tag_global', '', 'tag_global', 'tagpath', 'global', 'set']] | |
713 set tags=tagpath | |
714 call assert_equal([], g:options) | |
715 call assert_equal(g:opt[0], g:opt[1]) | |
716 | |
717 | |
718 " 20a: Setting string local (to buffer) option" | |
719 let oldval = &spelllang | |
720 let g:options=[['spelllang', oldval, oldval, oldval, 'elvish,klingon', 'global', 'set']] | |
721 set spelllang=elvish,klingon | |
722 call assert_equal([], g:options) | |
723 call assert_equal(g:opt[0], g:opt[1]) | |
724 | |
725 " 20b: Resetting string local (to buffer) option" | |
726 let g:options=[['spelllang', 'elvish,klingon', 'elvish,klingon', 'elvish,klingon', oldval, 'global', 'set']] | |
727 set spelllang& | |
728 call assert_equal([], g:options) | |
729 call assert_equal(g:opt[0], g:opt[1]) | |
730 | |
731 " 20c: Setting global string local (to buffer) option" | |
732 let g:options=[['spelllang', oldval, '', oldval, 'elvish', 'global', 'setglobal']] | |
733 setglobal spelllang=elvish | |
734 call assert_equal([], g:options) | |
735 call assert_equal(g:opt[0], g:opt[1]) | |
736 | |
737 " 20d: Setting local string local (to buffer) option" | |
738 noa set spelllang& " Reset global and local value (without triggering autocmd) | |
739 let g:options=[['spelllang', oldval, oldval, '', 'klingon', 'local', 'setlocal']] | |
740 setlocal spelllang=klingon | |
741 call assert_equal([], g:options) | |
742 call assert_equal(g:opt[0], g:opt[1]) | |
743 | |
744 " 20e: Setting again string local (to buffer) option" | |
745 " Note: v:option_old is the old global value for local-global string options | |
746 " but the old local value for all other kinds of options. | |
747 noa setglobal spelllang=spellglobal " Reset global and local value (without triggering autocmd) | |
748 noa setlocal spelllang=spelllocal | |
749 let g:options=[['spelllang', 'spelllocal', 'spelllocal', 'spellglobal', 'foo', 'global', 'set']] | |
750 set spelllang=foo | |
751 call assert_equal([], g:options) | |
752 call assert_equal(g:opt[0], g:opt[1]) | |
753 | |
754 | |
755 " 21a: Setting string local-global (to window) option" | |
756 let oldval = &statusline | |
757 let g:options=[['statusline', oldval, oldval, oldval, 'foo', 'global', 'set']] | |
758 set statusline=foo | |
759 call assert_equal([], g:options) | |
760 call assert_equal(g:opt[0], g:opt[1]) | |
761 | |
762 " 21b: Resetting string local-global (to window) option" | |
763 " Note: v:option_old is the old global value for local-global string options | |
764 " but the old local value for all other kinds of options. | |
765 let g:options=[['statusline', 'foo', 'foo', 'foo', oldval, 'global', 'set']] | |
766 set statusline& | |
767 call assert_equal([], g:options) | |
768 call assert_equal(g:opt[0], g:opt[1]) | |
769 | |
770 " 21c: Setting global string local-global (to window) option" | |
771 let g:options=[['statusline', oldval, '', oldval, 'bar', 'global', 'setglobal']] | |
772 setglobal statusline=bar | |
773 call assert_equal([], g:options) | |
774 call assert_equal(g:opt[0], g:opt[1]) | |
775 | |
776 " 21d: Setting local string local-global (to window) option" | |
777 noa set statusline& " Reset global and local value (without triggering autocmd) | |
778 let g:options=[['statusline', oldval, oldval, '', 'baz', 'local', 'setlocal']] | |
779 setlocal statusline=baz | |
780 call assert_equal([], g:options) | |
781 call assert_equal(g:opt[0], g:opt[1]) | |
782 | |
783 " 21e: Setting again string local-global (to window) option" | |
784 " Note: v:option_old is the old global value for local-global string options | |
785 " but the old local value for all other kinds of options. | |
786 noa setglobal statusline=bar " Reset global and local value (without triggering autocmd) | |
787 noa setlocal statusline=baz | |
788 let g:options=[['statusline', 'bar', 'baz', 'bar', 'foo', 'global', 'set']] | |
789 set statusline=foo | |
790 call assert_equal([], g:options) | |
791 call assert_equal(g:opt[0], g:opt[1]) | |
792 | |
793 | |
794 " 22a: Setting string local (to window) option" | |
795 let oldval = &foldignore | |
796 let g:options=[['foldignore', oldval, oldval, oldval, 'fo', 'global', 'set']] | |
797 set foldignore=fo | |
798 call assert_equal([], g:options) | |
799 call assert_equal(g:opt[0], g:opt[1]) | |
800 | |
801 " 22b: Resetting string local (to window) option" | |
802 let g:options=[['foldignore', 'fo', 'fo', 'fo', oldval, 'global', 'set']] | |
803 set foldignore& | |
804 call assert_equal([], g:options) | |
805 call assert_equal(g:opt[0], g:opt[1]) | |
806 | |
807 " 22c: Setting global string local (to window) option" | |
808 let g:options=[['foldignore', oldval, '', oldval, 'bar', 'global', 'setglobal']] | |
809 setglobal foldignore=bar | |
810 call assert_equal([], g:options) | |
811 call assert_equal(g:opt[0], g:opt[1]) | |
812 | |
813 " 22d: Setting local string local (to window) option" | |
814 noa set foldignore& " Reset global and local value (without triggering autocmd) | |
815 let g:options=[['foldignore', oldval, oldval, '', 'baz', 'local', 'setlocal']] | |
816 setlocal foldignore=baz | |
817 call assert_equal([], g:options) | |
818 call assert_equal(g:opt[0], g:opt[1]) | |
819 | |
820 " 22e: Setting again string local (to window) option" | |
821 noa setglobal foldignore=glob " Reset global and local value (without triggering autocmd) | |
822 noa setlocal foldignore=loc | |
823 let g:options=[['foldignore', 'loc', 'loc', 'glob', 'fo', 'global', 'set']] | |
824 set foldignore=fo | |
825 call assert_equal([], g:options) | |
826 call assert_equal(g:opt[0], g:opt[1]) | |
827 | |
828 | |
829 " 23a: Setting global number local option" | |
830 noa setglobal cmdheight=8 " Reset global and local value (without triggering autocmd) | |
831 noa setlocal cmdheight=1 " Sets the global(!) value! | |
832 let g:options=[['cmdheight', '1', '', '1', '2', 'global', 'setglobal']] | |
833 setglobal cmdheight=2 | |
834 call assert_equal([], g:options) | |
835 call assert_equal(g:opt[0], g:opt[1]) | |
836 | |
837 " 23b: Setting local number global option" | |
838 noa setglobal cmdheight=8 " Reset global and local value (without triggering autocmd) | |
839 noa setlocal cmdheight=1 " Sets the global(!) value! | |
840 let g:options=[['cmdheight', '1', '1', '', '2', 'local', 'setlocal']] | |
841 setlocal cmdheight=2 | |
842 call assert_equal([], g:options) | |
843 call assert_equal(g:opt[0], g:opt[1]) | |
844 | |
845 " 23c: Setting again number global option" | |
846 noa setglobal cmdheight=8 " Reset global and local value (without triggering autocmd) | |
847 noa setlocal cmdheight=1 " Sets the global(!) value! | |
848 let g:options=[['cmdheight', '1', '1', '1', '2', 'global', 'set']] | |
849 set cmdheight=2 | |
850 call assert_equal([], g:options) | |
851 call assert_equal(g:opt[0], g:opt[1]) | |
852 | |
853 " 23d: Setting again number global option" | |
854 noa set cmdheight=8 " Reset global and local value (without triggering autocmd) | |
855 let g:options=[['cmdheight', '8', '8', '8', '2', 'global', 'set']] | |
856 set cmdheight=2 | |
857 call assert_equal([], g:options) | |
858 call assert_equal(g:opt[0], g:opt[1]) | |
859 | |
860 | |
861 " 24a: Setting global number global-local (to buffer) option" | |
862 noa setglobal undolevels=8 " Reset global and local value (without triggering autocmd) | |
863 noa setlocal undolevels=1 | |
864 let g:options=[['undolevels', '8', '', '8', '2', 'global', 'setglobal']] | |
865 setglobal undolevels=2 | |
866 call assert_equal([], g:options) | |
867 call assert_equal(g:opt[0], g:opt[1]) | |
868 | |
869 " 24b: Setting local number global-local (to buffer) option" | |
870 noa setglobal undolevels=8 " Reset global and local value (without triggering autocmd) | |
871 noa setlocal undolevels=1 | |
872 let g:options=[['undolevels', '1', '1', '', '2', 'local', 'setlocal']] | |
873 setlocal undolevels=2 | |
874 call assert_equal([], g:options) | |
875 call assert_equal(g:opt[0], g:opt[1]) | |
876 | |
877 " 24c: Setting again number global-local (to buffer) option" | |
878 noa setglobal undolevels=8 " Reset global and local value (without triggering autocmd) | |
879 noa setlocal undolevels=1 | |
880 let g:options=[['undolevels', '1', '1', '8', '2', 'global', 'set']] | |
881 set undolevels=2 | |
882 call assert_equal([], g:options) | |
883 call assert_equal(g:opt[0], g:opt[1]) | |
884 | |
885 " 24d: Setting again global number global-local (to buffer) option" | |
886 noa set undolevels=8 " Reset global and local value (without triggering autocmd) | |
887 let g:options=[['undolevels', '8', '8', '8', '2', 'global', 'set']] | |
888 set undolevels=2 | |
889 call assert_equal([], g:options) | |
890 call assert_equal(g:opt[0], g:opt[1]) | |
891 | |
892 | |
893 " 25a: Setting global number local (to buffer) option" | |
894 noa setglobal wrapmargin=8 " Reset global and local value (without triggering autocmd) | |
895 noa setlocal wrapmargin=1 | |
896 let g:options=[['wrapmargin', '8', '', '8', '2', 'global', 'setglobal']] | |
897 setglobal wrapmargin=2 | |
898 call assert_equal([], g:options) | |
899 call assert_equal(g:opt[0], g:opt[1]) | |
900 | |
901 " 25b: Setting local number local (to buffer) option" | |
902 noa setglobal wrapmargin=8 " Reset global and local value (without triggering autocmd) | |
903 noa setlocal wrapmargin=1 | |
904 let g:options=[['wrapmargin', '1', '1', '', '2', 'local', 'setlocal']] | |
905 setlocal wrapmargin=2 | |
906 call assert_equal([], g:options) | |
907 call assert_equal(g:opt[0], g:opt[1]) | |
908 | |
909 " 25c: Setting again number local (to buffer) option" | |
910 noa setglobal wrapmargin=8 " Reset global and local value (without triggering autocmd) | |
911 noa setlocal wrapmargin=1 | |
912 let g:options=[['wrapmargin', '1', '1', '8', '2', 'global', 'set']] | |
913 set wrapmargin=2 | |
914 call assert_equal([], g:options) | |
915 call assert_equal(g:opt[0], g:opt[1]) | |
916 | |
917 " 25d: Setting again global number local (to buffer) option" | |
918 noa set wrapmargin=8 " Reset global and local value (without triggering autocmd) | |
919 let g:options=[['wrapmargin', '8', '8', '8', '2', 'global', 'set']] | |
920 set wrapmargin=2 | |
921 call assert_equal([], g:options) | |
922 call assert_equal(g:opt[0], g:opt[1]) | |
923 | |
924 | |
925 " 26: Setting number global-local (to window) option. | |
926 " Such option does currently not exist. | |
927 | |
928 | |
929 " 27a: Setting global number local (to window) option" | |
930 noa setglobal foldcolumn=8 " Reset global and local value (without triggering autocmd) | |
931 noa setlocal foldcolumn=1 | |
932 let g:options=[['foldcolumn', '8', '', '8', '2', 'global', 'setglobal']] | |
933 setglobal foldcolumn=2 | |
934 call assert_equal([], g:options) | |
935 call assert_equal(g:opt[0], g:opt[1]) | |
936 | |
937 " 27b: Setting local number local (to window) option" | |
938 noa setglobal foldcolumn=8 " Reset global and local value (without triggering autocmd) | |
939 noa setlocal foldcolumn=1 | |
940 let g:options=[['foldcolumn', '1', '1', '', '2', 'local', 'setlocal']] | |
941 setlocal foldcolumn=2 | |
942 call assert_equal([], g:options) | |
943 call assert_equal(g:opt[0], g:opt[1]) | |
944 | |
945 " 27c: Setting again number local (to window) option" | |
946 noa setglobal foldcolumn=8 " Reset global and local value (without triggering autocmd) | |
947 noa setlocal foldcolumn=1 | |
948 let g:options=[['foldcolumn', '1', '1', '8', '2', 'global', 'set']] | |
949 set foldcolumn=2 | |
950 call assert_equal([], g:options) | |
951 call assert_equal(g:opt[0], g:opt[1]) | |
952 | |
953 " 27d: Ssettin again global number local (to window) option" | |
954 noa set foldcolumn=8 " Reset global and local value (without triggering autocmd) | |
955 let g:options=[['foldcolumn', '8', '8', '8', '2', 'global', 'set']] | |
956 set foldcolumn=2 | |
957 call assert_equal([], g:options) | |
958 call assert_equal(g:opt[0], g:opt[1]) | |
959 | |
960 | |
961 " 28a: Setting global boolean global option" | |
962 noa setglobal nowrapscan " Reset global and local value (without triggering autocmd) | |
963 noa setlocal wrapscan " Sets the global(!) value! | |
964 let g:options=[['wrapscan', '1', '', '1', '0', 'global', 'setglobal']] | |
965 setglobal nowrapscan | |
966 call assert_equal([], g:options) | |
967 call assert_equal(g:opt[0], g:opt[1]) | |
968 | |
969 " 28b: Setting local boolean global option" | |
970 noa setglobal nowrapscan " Reset global and local value (without triggering autocmd) | |
971 noa setlocal wrapscan " Sets the global(!) value! | |
972 let g:options=[['wrapscan', '1', '1', '', '0', 'local', 'setlocal']] | |
973 setlocal nowrapscan | |
974 call assert_equal([], g:options) | |
975 call assert_equal(g:opt[0], g:opt[1]) | |
976 | |
977 " 28c: Setting again boolean global option" | |
978 noa setglobal nowrapscan " Reset global and local value (without triggering autocmd) | |
979 noa setlocal wrapscan " Sets the global(!) value! | |
980 let g:options=[['wrapscan', '1', '1', '1', '0', 'global', 'set']] | |
981 set nowrapscan | |
982 call assert_equal([], g:options) | |
983 call assert_equal(g:opt[0], g:opt[1]) | |
984 | |
985 " 28d: Setting again global boolean global option" | |
986 noa set nowrapscan " Reset global and local value (without triggering autocmd) | |
987 let g:options=[['wrapscan', '0', '0', '0', '1', 'global', 'set']] | |
988 set wrapscan | |
989 call assert_equal([], g:options) | |
990 call assert_equal(g:opt[0], g:opt[1]) | |
991 | |
992 | |
993 " 29a: Setting global boolean global-local (to buffer) option" | |
994 noa setglobal noautoread " Reset global and local value (without triggering autocmd) | |
995 noa setlocal autoread | |
996 let g:options=[['autoread', '0', '', '0', '1', 'global', 'setglobal']] | |
997 setglobal autoread | |
998 call assert_equal([], g:options) | |
999 call assert_equal(g:opt[0], g:opt[1]) | |
1000 | |
1001 " 29b: Setting local boolean global-local (to buffer) option" | |
1002 noa setglobal noautoread " Reset global and local value (without triggering autocmd) | |
1003 noa setlocal autoread | |
1004 let g:options=[['autoread', '1', '1', '', '0', 'local', 'setlocal']] | |
1005 setlocal noautoread | |
1006 call assert_equal([], g:options) | |
1007 call assert_equal(g:opt[0], g:opt[1]) | |
1008 | |
1009 " 29c: Setting again boolean global-local (to buffer) option" | |
1010 noa setglobal noautoread " Reset global and local value (without triggering autocmd) | |
1011 noa setlocal autoread | |
1012 let g:options=[['autoread', '1', '1', '0', '1', 'global', 'set']] | |
1013 set autoread | |
1014 call assert_equal([], g:options) | |
1015 call assert_equal(g:opt[0], g:opt[1]) | |
1016 | |
1017 " 29d: Setting again global boolean global-local (to buffer) option" | |
1018 noa set noautoread " Reset global and local value (without triggering autocmd) | |
1019 let g:options=[['autoread', '0', '0', '0', '1', 'global', 'set']] | |
1020 set autoread | |
1021 call assert_equal([], g:options) | |
1022 call assert_equal(g:opt[0], g:opt[1]) | |
1023 | |
1024 | |
1025 " 30a: Setting global boolean local (to buffer) option" | |
1026 noa setglobal nocindent " Reset global and local value (without triggering autocmd) | |
1027 noa setlocal cindent | |
1028 let g:options=[['cindent', '0', '', '0', '1', 'global', 'setglobal']] | |
1029 setglobal cindent | |
1030 call assert_equal([], g:options) | |
1031 call assert_equal(g:opt[0], g:opt[1]) | |
1032 | |
1033 " 30b: Setting local boolean local (to buffer) option" | |
1034 noa setglobal nocindent " Reset global and local value (without triggering autocmd) | |
1035 noa setlocal cindent | |
1036 let g:options=[['cindent', '1', '1', '', '0', 'local', 'setlocal']] | |
1037 setlocal nocindent | |
1038 call assert_equal([], g:options) | |
1039 call assert_equal(g:opt[0], g:opt[1]) | |
1040 | |
1041 " 30c: Setting again boolean local (to buffer) option" | |
1042 noa setglobal nocindent " Reset global and local value (without triggering autocmd) | |
1043 noa setlocal cindent | |
1044 let g:options=[['cindent', '1', '1', '0', '1', 'global', 'set']] | |
1045 set cindent | |
1046 call assert_equal([], g:options) | |
1047 call assert_equal(g:opt[0], g:opt[1]) | |
1048 | |
1049 " 30d: Setting again global boolean local (to buffer) option" | |
1050 noa set nocindent " Reset global and local value (without triggering autocmd) | |
1051 let g:options=[['cindent', '0', '0', '0', '1', 'global', 'set']] | |
1052 set cindent | |
1053 call assert_equal([], g:options) | |
1054 call assert_equal(g:opt[0], g:opt[1]) | |
1055 | |
1056 | |
1057 " 31: Setting boolean global-local (to window) option | |
1058 " Currently no such option exists. | |
1059 | |
1060 | |
1061 " 32a: Setting global boolean local (to window) option" | |
1062 noa setglobal nocursorcolumn " Reset global and local value (without triggering autocmd) | |
1063 noa setlocal cursorcolumn | |
1064 let g:options=[['cursorcolumn', '0', '', '0', '1', 'global', 'setglobal']] | |
1065 setglobal cursorcolumn | |
1066 call assert_equal([], g:options) | |
1067 call assert_equal(g:opt[0], g:opt[1]) | |
1068 | |
1069 " 32b: Setting local boolean local (to window) option" | |
1070 noa setglobal nocursorcolumn " Reset global and local value (without triggering autocmd) | |
1071 noa setlocal cursorcolumn | |
1072 let g:options=[['cursorcolumn', '1', '1', '', '0', 'local', 'setlocal']] | |
1073 setlocal nocursorcolumn | |
1074 call assert_equal([], g:options) | |
1075 call assert_equal(g:opt[0], g:opt[1]) | |
1076 | |
1077 " 32c: Setting again boolean local (to window) option" | |
1078 noa setglobal nocursorcolumn " Reset global and local value (without triggering autocmd) | |
1079 noa setlocal cursorcolumn | |
1080 let g:options=[['cursorcolumn', '1', '1', '0', '1', 'global', 'set']] | |
1081 set cursorcolumn | |
1082 call assert_equal([], g:options) | |
1083 call assert_equal(g:opt[0], g:opt[1]) | |
1084 | |
1085 " 32d: Setting again global boolean local (to window) option" | |
1086 noa set nocursorcolumn " Reset global and local value (without triggering autocmd) | |
1087 let g:options=[['cursorcolumn', '0', '0', '0', '1', 'global', 'set']] | |
1088 set cursorcolumn | |
1089 call assert_equal([], g:options) | |
1090 call assert_equal(g:opt[0], g:opt[1]) | |
1091 | |
1092 | |
1093 " 33: Test autocomands when an option value is converted internally. | |
1094 noa set backspace=1 " Reset global and local value (without triggering autocmd) | |
1095 let g:options=[['backspace', 'indent,eol', 'indent,eol', 'indent,eol', '2', 'global', 'set']] | |
1096 set backspace=2 | |
1097 call assert_equal([], g:options) | |
1098 call assert_equal(g:opt[0], g:opt[1]) | |
1099 | |
637 | 1100 |
638 " Cleanup | 1101 " Cleanup |
639 au! OptionSet | 1102 au! OptionSet |
640 for opt in ['nu', 'ai', 'acd', 'ar', 'bs', 'backup', 'cul', 'cp'] | 1103 for opt in ['nu', 'ai', 'acd', 'ar', 'bs', 'backup', 'cul', 'cp', 'backupext', 'tags', 'spelllang', 'statusline', 'foldignore', 'cmdheight', 'undolevels', 'wrapmargin', 'foldcolumn', 'wrapscan', 'autoread', 'cindent', 'cursorcolumn'] |
641 exe printf(":set %s&vim", opt) | 1104 exe printf(":set %s&vim", opt) |
642 endfor | 1105 endfor |
643 call test_override('starting', 0) | 1106 call test_override('starting', 0) |
644 delfunc! AutoCommandOptionSet | 1107 delfunc! AutoCommandOptionSet |
645 endfunc | 1108 endfunc |