comparison src/testdir/test_vim9_import.vim @ 27301:ebe56a24acb6 v8.2.4179

patch 8.2.4179: 'foldtext' is evaluated in the current script context Commit: https://github.com/vim/vim/commit/9530b580a7b71960dbbdb2b12a3aafeb540bd135 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 22 13:39:08 2022 +0000 patch 8.2.4179: 'foldtext' is evaluated in the current script context Problem: 'foldtext' is evaluated in the current script context. Solution: Use the script context where the option was set.
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Jan 2022 14:45:02 +0100
parents f7cb41ff22a4
children 30d8437ad7cc
comparison
equal deleted inserted replaced
27300:160b87e56c45 27301:ebe56a24acb6
681 var lines =<< trim END 681 var lines =<< trim END
682 vim9script 682 vim9script
683 export def Expr(): string 683 export def Expr(): string
684 return getline(v:lnum) =~ '^#' ? '>1' : '1' 684 return getline(v:lnum) =~ '^#' ? '>1' : '1'
685 enddef 685 enddef
686 export def Text(): string
687 return 'fold text'
688 enddef
686 g:fold_loaded = 'yes' 689 g:fold_loaded = 'yes'
687 END 690 END
688 writefile(lines, 'Xdir/autoload/fold.vim') 691 writefile(lines, 'Xdir/autoload/fold.vim')
689 692
690 lines =<< trim END 693 lines =<< trim END
691 vim9script 694 vim9script
692 import autoload 'fold.vim' 695 import autoload 'fold.vim'
693 &foldexpr = 'fold.Expr()' 696 &foldexpr = 'fold.Expr()'
697 &foldtext = 'fold.Text()'
694 &foldmethod = 'expr' 698 &foldmethod = 'expr'
695 &debug = 'throw' 699 &debug = 'throw'
696 END 700 END
697 new 701 new
698 setline(1, ['# one', 'text', '# two', 'text']) 702 setline(1, ['# one', 'text', '# two', 'text'])
704 708
705 # Check that script context of 'foldexpr' is copied to another buffer. 709 # Check that script context of 'foldexpr' is copied to another buffer.
706 edit! otherfile 710 edit! otherfile
707 redraw 711 redraw
708 712
709 set foldexpr= foldmethod& debug= 713 set foldexpr= foldtext& foldmethod& debug=
710 bwipe! 714 bwipe!
711 delete('Xdir', 'rf') 715 delete('Xdir', 'rf')
712 &rtp = save_rtp 716 &rtp = save_rtp
713 enddef 717 enddef
714 718