components/vim/vim72-patches/7.2.274
changeset 198 172fc01ce997
equal deleted inserted replaced
197:fd801ec0737c 198:172fc01ce997
       
     1 To: [email protected]
       
     2 Subject: Patch 7.2.274
       
     3 Fcc: outbox
       
     4 From: Bram Moolenaar <[email protected]>
       
     5 Mime-Version: 1.0
       
     6 Content-Type: text/plain; charset=UTF-8
       
     7 Content-Transfer-Encoding: 8bit
       
     8 ------------
       
     9 
       
    10 Patch 7.2.274
       
    11 Problem:    Syntax folding doesn't work properly when adding a comment.
       
    12 Solution:   Fix it and add a test. (Lech Lorens)
       
    13 Files:	    src/fold.c, src/testdir/test45.in, src/testdir/test45.ok
       
    14 
       
    15 
       
    16 *** ../vim-7.2.273/src/fold.c	2009-09-18 15:16:37.000000000 +0200
       
    17 --- src/fold.c	2009-11-03 12:36:37.000000000 +0100
       
    18 ***************
       
    19 *** 2256,2261 ****
       
    20 --- 2256,2295 ----
       
    21   	}
       
    22       }
       
    23   
       
    24 +     /*
       
    25 +      * If folding is defined by the syntax, it is possible that a change in
       
    26 +      * one line will cause all sub-folds of the current fold to change (e.g.,
       
    27 +      * closing a C-style comment can cause folds in the subsequent lines to
       
    28 +      * appear). To take that into account we should adjust the value of "bot"
       
    29 +      * to point to the end of the current fold:
       
    30 +      */
       
    31 +     if (foldlevelSyntax == getlevel)
       
    32 +     {
       
    33 + 	garray_T *gap = &wp->w_folds;
       
    34 + 	fold_T	 *fp = NULL;
       
    35 + 	int	  current_fdl = 0;
       
    36 + 	linenr_T  fold_start_lnum = 0;
       
    37 + 	linenr_T  lnum_rel = fline.lnum;
       
    38 + 
       
    39 + 	while (current_fdl < fline.lvl)
       
    40 + 	{
       
    41 + 	    if (!foldFind(gap, lnum_rel, &fp))
       
    42 + 		break;
       
    43 + 	    ++current_fdl;
       
    44 + 
       
    45 + 	    fold_start_lnum += fp->fd_top;
       
    46 + 	    gap = &fp->fd_nested;
       
    47 + 	    lnum_rel -= fp->fd_top;
       
    48 + 	}
       
    49 + 	if (fp != NULL && current_fdl == fline.lvl)
       
    50 + 	{
       
    51 + 	    linenr_T fold_end_lnum = fold_start_lnum + fp->fd_len;
       
    52 + 
       
    53 + 	    if (fold_end_lnum > bot)
       
    54 + 		bot = fold_end_lnum;
       
    55 + 	}
       
    56 +     }
       
    57 + 
       
    58       start = fline.lnum;
       
    59       end = bot;
       
    60       /* Do at least one line. */
       
    61 *** ../vim-7.2.273/src/testdir/test45.in	2007-09-25 17:58:43.000000000 +0200
       
    62 --- src/testdir/test45.in	2009-11-03 12:22:38.000000000 +0100
       
    63 ***************
       
    64 *** 28,36 ****
       
    65   k:call append("$", foldlevel("."))
       
    66   :" test syntax folding
       
    67   :set fdm=syntax fdl=0
       
    68 ! :syn region Hup start="dd" end="hh" fold
       
    69   Gzk:call append("$", "folding " . getline("."))
       
    70   k:call append("$", getline("."))
       
    71   :" test expression folding
       
    72   :fun Flvl()
       
    73     let l = getline(v:lnum)
       
    74 --- 28,41 ----
       
    75   k:call append("$", foldlevel("."))
       
    76   :" test syntax folding
       
    77   :set fdm=syntax fdl=0
       
    78 ! :syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
       
    79 ! :syn region Fd1 start="ee" end="ff" fold contained
       
    80 ! :syn region Fd2 start="gg" end="hh" fold contained
       
    81 ! :syn region Fd3 start="commentstart" end="commentend" fold contained
       
    82   Gzk:call append("$", "folding " . getline("."))
       
    83   k:call append("$", getline("."))
       
    84 + jAcommentstart  Acommentend:set fdl=1
       
    85 + 3j:call append("$", getline("."))
       
    86   :" test expression folding
       
    87   :fun Flvl()
       
    88     let l = getline(v:lnum)
       
    89 *** ../vim-7.2.273/src/testdir/test45.ok	2004-06-13 17:47:37.000000000 +0200
       
    90 --- src/testdir/test45.ok	2009-11-03 12:22:50.000000000 +0100
       
    91 ***************
       
    92 *** 8,15 ****
       
    93   0
       
    94   indent 2
       
    95   1
       
    96 ! folding 8 hh
       
    97       3 cc
       
    98   expr 2
       
    99   1
       
   100   2
       
   101 --- 8,16 ----
       
   102   0
       
   103   indent 2
       
   104   1
       
   105 ! folding 9 ii
       
   106       3 cc
       
   107 + 7 gg
       
   108   expr 2
       
   109   1
       
   110   2
       
   111 *** ../vim-7.2.273/src/version.c	2009-11-03 14:26:29.000000000 +0100
       
   112 --- src/version.c	2009-11-03 14:44:21.000000000 +0100
       
   113 ***************
       
   114 *** 678,679 ****
       
   115 --- 678,681 ----
       
   116   {   /* Add new patch number below this line */
       
   117 + /**/
       
   118 +     274,
       
   119   /**/
       
   120 
       
   121 -- 
       
   122 BRIDGEKEEPER: What is your favorite colour?
       
   123 LAUNCELOT:    Blue.
       
   124 BRIDGEKEEPER: Right.  Off you go.
       
   125                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
       
   126 
       
   127  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
       
   128 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
       
   129 \\\        download, build and distribute -- http://www.A-A-P.org        ///
       
   130  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///