Mercurial > vim
comparison src/eval.c @ 14700:0a3b9ecf7cb8 v8.1.0362
patch 8.1.0362: cannot get the script line number when executing a function
commit https://github.com/vim/vim/commit/f29c1c6aa3f365c025890fab5fb9efbe88eb1761
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 10 21:05:02 2018 +0200
patch 8.1.0362: cannot get the script line number when executing a function
Problem: Cannot get the script line number when executing a function.
Solution: Store the line number besides the script ID. (Ozaki Kiichi,
closes #3362) Also display the line number with ":verbose set".
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 10 Sep 2018 21:15:07 +0200 |
parents | e4c553e9132b |
children | 27b9a84395b5 |
comparison
equal
deleted
inserted
replaced
14699:2d2a36710dad | 14700:0a3b9ecf7cb8 |
---|---|
1493 * List script-local variables, if there is a script. | 1493 * List script-local variables, if there is a script. |
1494 */ | 1494 */ |
1495 static void | 1495 static void |
1496 list_script_vars(int *first) | 1496 list_script_vars(int *first) |
1497 { | 1497 { |
1498 if (current_SID > 0 && current_SID <= ga_scripts.ga_len) | 1498 if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= ga_scripts.ga_len) |
1499 list_hashtable_vars(&SCRIPT_VARS(current_SID), | 1499 list_hashtable_vars(&SCRIPT_VARS(current_sctx.sc_sid), |
1500 (char_u *)"s:", FALSE, first); | 1500 (char_u *)"s:", FALSE, first); |
1501 } | 1501 } |
1502 | 1502 |
1503 /* | 1503 /* |
1504 * List variables in "arg". | 1504 * List variables in "arg". |
7200 if (*varname == NUL) | 7200 if (*varname == NUL) |
7201 { | 7201 { |
7202 /* Must be something like "s:", otherwise "ht" would be NULL. */ | 7202 /* Must be something like "s:", otherwise "ht" would be NULL. */ |
7203 switch (htname) | 7203 switch (htname) |
7204 { | 7204 { |
7205 case 's': return &SCRIPT_SV(current_SID)->sv_var; | 7205 case 's': return &SCRIPT_SV(current_sctx.sc_sid)->sv_var; |
7206 case 'g': return &globvars_var; | 7206 case 'g': return &globvars_var; |
7207 case 'v': return &vimvars_var; | 7207 case 'v': return &vimvars_var; |
7208 case 'b': return &curbuf->b_bufvar; | 7208 case 'b': return &curbuf->b_bufvar; |
7209 case 'w': return &curwin->w_winvar; | 7209 case 'w': return &curwin->w_winvar; |
7210 case 't': return &curtab->tp_winvar; | 7210 case 't': return &curtab->tp_winvar; |
7284 if (*name == 'a') /* a: function argument */ | 7284 if (*name == 'a') /* a: function argument */ |
7285 return get_funccal_args_ht(); | 7285 return get_funccal_args_ht(); |
7286 if (*name == 'l') /* l: local function variable */ | 7286 if (*name == 'l') /* l: local function variable */ |
7287 return get_funccal_local_ht(); | 7287 return get_funccal_local_ht(); |
7288 if (*name == 's' /* script variable */ | 7288 if (*name == 's' /* script variable */ |
7289 && current_SID > 0 && current_SID <= ga_scripts.ga_len) | 7289 && current_sctx.sc_sid > 0 && current_sctx.sc_sid <= ga_scripts.ga_len) |
7290 return &SCRIPT_VARS(current_SID); | 7290 return &SCRIPT_VARS(current_sctx.sc_sid); |
7291 return NULL; | 7291 return NULL; |
7292 } | 7292 } |
7293 | 7293 |
7294 /* | 7294 /* |
7295 * Get the string value of a (global/local) variable. | 7295 * Get the string value of a (global/local) variable. |
8727 /* | 8727 /* |
8728 * Display script name where an item was last set. | 8728 * Display script name where an item was last set. |
8729 * Should only be invoked when 'verbose' is non-zero. | 8729 * Should only be invoked when 'verbose' is non-zero. |
8730 */ | 8730 */ |
8731 void | 8731 void |
8732 last_set_msg(scid_T scriptID) | 8732 last_set_msg(sctx_T script_ctx) |
8733 { | 8733 { |
8734 char_u *p; | 8734 char_u *p; |
8735 | 8735 |
8736 if (scriptID != 0) | 8736 if (script_ctx.sc_sid != 0) |
8737 { | 8737 { |
8738 p = home_replace_save(NULL, get_scriptname(scriptID)); | 8738 p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid)); |
8739 if (p != NULL) | 8739 if (p != NULL) |
8740 { | 8740 { |
8741 verbose_enter(); | 8741 verbose_enter(); |
8742 MSG_PUTS(_("\n\tLast set from ")); | 8742 MSG_PUTS(_("\n\tLast set from ")); |
8743 MSG_PUTS(p); | 8743 MSG_PUTS(p); |
8744 if (script_ctx.sc_lnum > 0) | |
8745 { | |
8746 MSG_PUTS(_(" line ")); | |
8747 msg_outnum((long)script_ctx.sc_lnum); | |
8748 } | |
8749 verbose_leave(); | |
8744 vim_free(p); | 8750 vim_free(p); |
8745 verbose_leave(); | |
8746 } | 8751 } |
8747 } | 8752 } |
8748 } | 8753 } |
8749 | 8754 |
8750 /* reset v:option_new, v:option_old and v:option_type */ | 8755 /* reset v:option_new, v:option_old and v:option_type */ |