Mercurial > vim
comparison src/userfunc.c @ 20816:9faab49c880f v8.2.0960
patch 8.2.0960: cannot use :import in legacy Vim script
Commit: https://github.com/vim/vim/commit/9721fb4ea3db2559aaf7f71458da8ddda30ff93e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 11 23:10:46 2020 +0200
patch 8.2.0960: cannot use :import in legacy Vim script
Problem: Cannot use :import in legacy Vim script.
Solution: Support :import in any Vim script.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 11 Jun 2020 23:15:03 +0200 |
parents | a2262c80a4e0 |
children | 9064044fd4f6 |
comparison
equal
deleted
inserted
replaced
20815:1b780bd39c59 | 20816:9faab49c880f |
---|---|
717 { | 717 { |
718 hashitem_T *hi; | 718 hashitem_T *hi; |
719 ufunc_T *func; | 719 ufunc_T *func; |
720 imported_T *imported; | 720 imported_T *imported; |
721 | 721 |
722 if (in_vim9script() && !is_global) | 722 if (!is_global) |
723 { | 723 { |
724 // Find script-local function before global one. | 724 char_u *after_script = NULL; |
725 func = find_func_with_sid(name, current_sctx.sc_sid); | 725 |
726 if (func != NULL) | 726 if (in_vim9script()) |
727 return func; | 727 { |
728 | 728 // Find script-local function before global one. |
729 // Find imported funcion before global one. | 729 func = find_func_with_sid(name, current_sctx.sc_sid); |
730 imported = find_imported(name, 0, cctx); | 730 if (func != NULL) |
731 if (imported != NULL && imported->imp_funcname != NULL) | 731 return func; |
732 { | 732 } |
733 hi = hash_find(&func_hashtab, imported->imp_funcname); | 733 |
734 if (!HASHITEM_EMPTY(hi)) | 734 if (!in_vim9script() |
735 return HI2UF(hi); | 735 && name[0] == K_SPECIAL |
736 && name[1] == KS_EXTRA | |
737 && name[2] == KE_SNR) | |
738 { | |
739 long sid; | |
740 | |
741 // Caller changes s: to <SNR>99_name. | |
742 | |
743 after_script = name + 3; | |
744 sid = getdigits(&after_script); | |
745 if (sid == current_sctx.sc_sid && *after_script == '_') | |
746 ++after_script; | |
747 else | |
748 after_script = NULL; | |
749 } | |
750 if (in_vim9script() || after_script != NULL) | |
751 { | |
752 // Find imported function before global one. | |
753 imported = find_imported( | |
754 after_script == NULL ? name : after_script, 0, cctx); | |
755 if (imported != NULL && imported->imp_funcname != NULL) | |
756 { | |
757 hi = hash_find(&func_hashtab, imported->imp_funcname); | |
758 if (!HASHITEM_EMPTY(hi)) | |
759 return HI2UF(hi); | |
760 } | |
736 } | 761 } |
737 } | 762 } |
738 | 763 |
739 hi = hash_find(&func_hashtab, | 764 hi = hash_find(&func_hashtab, |
740 STRNCMP(name, "g:", 2) == 0 ? name + 2 : name); | 765 STRNCMP(name, "g:", 2) == 0 ? name + 2 : name); |