Roland Eggner wrote:
On 2014-12-12 Friday at 09:46 +0200 Marius Gedminas wrote:
On Fri, Dec 12, 2014 at 12:57:39AM +0100, Roland Eggner wrote:
Patch "Make closed folds line up" by Charles Campbell is already on Brams todo 
list.
http://www.drchip.org/astronaut/vim/patch/folding.ptch

It works nicely apart from case "relativenumber nonumber" with numberwidth
smaller than for absolute linenumbers would be appropriate.  And in this
particular case, I am encountering rare crashes -- both with and without the
named patch applied, “foldmethod=expr” and „syntax on” always in effect.  So far
I cannot reproduce the crashes, they are too rare.

E.g. with terminal LINES=90 relativenumbers are never longer than 2 digits, thus
I set numberwidth=3.  If the buffer holds a file with >10000 lines of text,
numberwidth<6 seems to be not considered in all related code parts, the
relativenumbers are consuming part of the padding introduced by the patch, which
does not look as nice as with “norelativenumber number” set.


With the patch applied:
*** glibc detected *** ../vim: free(): invalid next size (fast): 
0x000005cd68894730 ***
Have you tried running vim under valgrind?
Sorry, I can only provide testing of patches … not enough bandwidth for building
a debugging environment these days.

Hello!

Please try the attached, modified folding patch. One advantage it has is that there are no fixed length buffers involved.

Regards,
Chip Campbell

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
*** keep_eval.c 2014-12-24 15:35:53.979883569 -0500
--- eval.c      2014-12-24 15:33:08.099984958 -0500
***************
*** 11032,11038 ****
--- 11032,11043 ----
      char_u    *s;
      char_u    *r;
      int               len;
+     int               flen;
      char      *txt;
+     char        *fmt;
+     int         nuw;
+     int         padding;
+     unsigned    rlen;
  #endif
  
      rettv->v_type = VAR_STRING;
***************
*** 11066,11087 ****
                    s = skipwhite(s + 1);
            }
        }
!       txt = _("+-%s%3ld lines: ");
!       r = alloc((unsigned)(STRLEN(txt)
!                   + STRLEN(vimvars[VV_FOLDDASHES].vv_str)    /* for %s */
!                   + 20                                    /* for %3ld */
!                   + STRLEN(s)));                          /* concatenated */
!       if (r != NULL)
!       {
!           sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str,
!                   (long)((linenr_T)vimvars[VV_FOLDEND].vv_nr
!                               - (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1));
            len = (int)STRLEN(r);
            STRCAT(r, s);
            /* remove 'foldmarker' and 'commentstring' */
            foldtext_cleanup(r + len);
            rettv->vval.v_string = r;
        }
      }
  #endif
  }
--- 11071,11105 ----
                    s = skipwhite(s + 1);
            }
        }
!       /* next two lines construct a format to be used for the folded region.
!        * Example: assume nuw=5, then fmt becomes "+-%-5s%5ld lines: %*s"
!        */
!       nuw    = number_width(curwin);  /* obtain log10(lastline) */
!       padding= STRLEN(vimvars[VV_FOLDDASHES].vv_str);
!       txt = _("lines");                       /* internationalize */
!       flen= 14 + STRLEN(txt) + 2*nuw + ((padding > nuw)? padding : nuw);
!       fmt = alloc(flen+1);
!       vim_snprintf(fmt,flen,"+-%%-%ds%%%dld %s:%%*s",(padding > nuw)? padding 
: nuw,nuw,txt);
!       fmt[flen]= '\0';
!       rlen= STRLEN(txt) + 2*nuw + ((padding > nuw)? padding : nuw) + 
STRLEN(s) + 4; /* 4: allows for 3-digit relative numbering and a null byte */
!       r   = alloc(rlen+1);
!       {FILE *fp; fp= fopen("/home/cec/folding.out","a"); fprintf(fp,"txt<%s> 
flen=%d rlen=%d nuw=%d padding=%d strlen(s)=%d strlen(lines)=%d fmt<%s>\n", 
txt,flen,rlen,nuw,padding,STRLEN(s),STRLEN(txt),fmt); fclose(fp); } /* COMBAK */
!       if (r != NULL && fmt != NULL)
!       {
!           if(padding > nuw) padding= nuw;
!           vim_snprintf((char *)r,rlen,fmt,
!             vimvars[VV_FOLDDASHES].vv_str,
!             (long)((linenr_T)vimvars[VV_FOLDEND].vv_nr - 
(linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1),
!             padding," ");
!           r[rlen]= '\0';
            len = (int)STRLEN(r);
            STRCAT(r, s);
            /* remove 'foldmarker' and 'commentstring' */
            foldtext_cleanup(r + len);
            rettv->vval.v_string = r;
+           vim_free(fmt);
        }
+       else if(fmt) vim_free(fmt);
      }
  #endif
  }

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui