From ed65724e57d2af13cedc380ecfe4a495dae3afb7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Aug 2022 07:07:32 +0800 Subject: vim-patch:8.2.1653: expand('') does not include the final line number Problem: Expand('') does not include the final line number. Solution: Add the line nuber. (closes vim/vim#6927) https://github.com/vim/vim/commit/4f25b1aba050b85fa97ca2316aa04dd4b0b22530 --- src/nvim/runtime.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/nvim/runtime.c') diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 1cafd22b0a..fba3dce92d 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -100,11 +100,11 @@ void estack_pop(void) } /// Get the current value for in allocated memory. -/// @param is_sfile true for itself. -char *estack_sfile(bool is_sfile) +/// @param which ESTACK_SFILE for and ESTACK_STACK for . +char *estack_sfile(estack_arg_T which) { estack_T *entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1; - if (is_sfile && entry->es_type != ETYPE_UFUNC) { + if (which == ESTACK_SFILE && entry->es_type != ETYPE_UFUNC) { if (entry->es_name == NULL) { return NULL; } @@ -135,14 +135,21 @@ char *estack_sfile(bool is_sfile) } len += strlen(type_name); ga_grow(&ga, (int)len); - if (idx == exestack.ga_len - 1 || entry->es_lnum == 0) { - // For the bottom entry: do not add the line number, it is used - // in . Also leave it out when the number is not set. + linenr_T lnum = 0; + if (idx == exestack.ga_len - 1) { + lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0; + } else { + lnum = entry->es_lnum; + } + if (lnum == 0) { + // For the bottom entry of : do not add the line number, + // it is used in . Also leave it out when the number is + // not set. vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s%s", type_name, entry->es_name, idx == exestack.ga_len - 1 ? "" : ".."); } else { vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%" PRIdLINENR "]..", - type_name, entry->es_name, entry->es_lnum); + type_name, entry->es_name, lnum); } ga.ga_len += (int)strlen((char *)ga.ga_data + ga.ga_len); } -- cgit