]> granicus.if.org Git - vim/commitdiff
patch 8.2.1658: expand('<stack>') has trailing ".." v8.2.1658
authorBram Moolenaar <Bram@vim.org>
Fri, 11 Sep 2020 15:59:23 +0000 (17:59 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 11 Sep 2020 15:59:23 +0000 (17:59 +0200)
Problem:    Expand('<stack>') has trailing "..".
Solution:   Remove the "..". (closes #6927)

src/scriptfile.c
src/testdir/test_expand_func.vim
src/version.c

index 75182ca511487322186de6ff54c053942b671c31..a8e67b98ad71aaf513c1665f5f6cdad6c05dcbd4 100644 (file)
@@ -144,7 +144,8 @@ estack_sfile(estack_arg_T which UNUSED)
        entry = ((estack_T *)exestack.ga_data) + idx;
        if (entry->es_name != NULL)
        {
-           long lnum = 0;
+           long    lnum = 0;
+           char    *dots;
 
            len = STRLEN(entry->es_name) + 15;
            type_name = "";
@@ -165,16 +166,16 @@ estack_sfile(estack_arg_T which UNUSED)
                lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;
            else
                lnum = entry->es_lnum;
+           dots = idx == exestack.ga_len - 1 ? "" : "..";
            if (lnum == 0)
                // For the bottom entry of <sfile>: do not add the line number,
                // it is used in <slnum>.  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 ? "" : "..");
+                               type_name, entry->es_name, dots);
            else
-               vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%ld]..",
-                                   type_name, entry->es_name, lnum);
+               vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%ld]%s",
+                                   type_name, entry->es_name, lnum, dots);
            ga.ga_len += (int)STRLEN((char *)ga.ga_data + ga.ga_len);
        }
     }
index a63cc04e1f97faae12dd354b704388dba8972589..3c430e1c6130caa5d71a80a6f31c4ebeae08c42d 100644 (file)
@@ -58,7 +58,7 @@ func Test_expand_sfile_and_stack()
   END
   call writefile(lines, 'Xstack')
   source Xstack
-  call assert_match('\<Xstack\[2\]', g:stack_value)
+  call assert_match('\<Xstack\[2\]$', g:stack_value)
   call delete('Xstack')
 endfunc
 
index 53868220345aa0349d1438e7618c7b50ce8730a9..81c51e196447fc9e761fee20cab13820043f8e65 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1658,
 /**/
     1657,
 /**/