home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.165 < prev    next >
Encoding:
Internet Message Format  |  2002-11-04  |  6.2 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.165
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.165
  11. Problem:    Making changes in several lines and then a change in one of these
  12.         lines that splits it in two or more lines, undo information was
  13.         corrupted.  May cause a crash. (Dave Fishburn)
  14. Solution:   When skipping to save a line for undo because it was already
  15.         saved, move it to become the last saved line, so that when the
  16.         command changes the line count other saved lines are not involved.
  17. Files:        src/undo.c
  18.  
  19.  
  20. *** ../vim61.164/src/undo.c    Tue Apr  9 23:19:52 2002
  21. --- src/undo.c    Sat Aug 24 23:11:19 2002
  22. ***************
  23. *** 155,160 ****
  24. --- 155,161 ----
  25.       long        i;
  26.       struct u_header    *uhp;
  27.       u_entry_T        *uep;
  28. +     u_entry_T        *prev_uep;
  29.       long        size;
  30.   
  31.       /*
  32. ***************
  33. *** 258,310 ****
  34.       if (size == 1)
  35.       {
  36.           uep = u_get_headentry();
  37.           for (i = 0; i < 10; ++i)
  38.           {
  39.           if (uep == NULL)
  40.               break;
  41.   
  42. !         /* If lines have been inserted/deleted we give up. */
  43. !         if (curbuf->b_u_newhead->uh_getbot_entry != uep
  44. !             ? (uep->ue_top + uep->ue_size + 1
  45. !                 != (uep->ue_bot == 0
  46. !                 ? curbuf->b_ml.ml_line_count + 1
  47. !                 : uep->ue_bot))
  48. !             : uep->ue_lcount != curbuf->b_ml.ml_line_count)
  49.               break;
  50.   
  51.           /* If it's the same line we can skip saving it again. */
  52.           if (uep->ue_size == 1 && uep->ue_top == top)
  53.           {
  54. -             /* If it's not the last entry, get ue_bot for the last
  55. -              * entry now.  Following deleted/inserted lines go to the
  56. -              * re-used entry. */
  57.               if (i > 0)
  58.               {
  59.               u_getbot();
  60.               curbuf->b_u_synced = FALSE;
  61.               }
  62.   
  63. !             /* The line count might change afterwards. */
  64.               if (newbot != 0)
  65. -             {
  66. -             /* When changing the line count and it's not the
  67. -              * newest entry, must adjust the line numbers of older
  68. -              * entries. */
  69. -             if (uep != curbuf->b_u_newhead->uh_entry
  70. -                              && uep->ue_bot != newbot)
  71. -             {
  72. -                 u_entry_T    *p;
  73. -                 for (p = curbuf->b_u_newhead->uh_entry;
  74. -                              p != uep; p = p->ue_next)
  75. -                 {
  76. -                 if (p->ue_bot != 0)
  77. -                     p->ue_bot -= uep->ue_bot - newbot;
  78. -                 p->ue_top -= uep->ue_bot - newbot;
  79. -                 }
  80. -             }
  81.               uep->ue_bot = newbot;
  82. -             }
  83.               else if (bot > curbuf->b_ml.ml_line_count)
  84.               uep->ue_bot = 0;
  85.               else
  86. --- 259,308 ----
  87.       if (size == 1)
  88.       {
  89.           uep = u_get_headentry();
  90. +         prev_uep = NULL;
  91.           for (i = 0; i < 10; ++i)
  92.           {
  93.           if (uep == NULL)
  94.               break;
  95.   
  96. !         /* If lines have been inserted/deleted we give up.
  97. !          * Also when the line was included in a multi-line save. */
  98. !         if ((curbuf->b_u_newhead->uh_getbot_entry != uep
  99. !                 ? (uep->ue_top + uep->ue_size + 1
  100. !                 != (uep->ue_bot == 0
  101. !                     ? curbuf->b_ml.ml_line_count + 1
  102. !                     : uep->ue_bot))
  103. !                 : uep->ue_lcount != curbuf->b_ml.ml_line_count)
  104. !             || (uep->ue_size > 1
  105. !                 && top >= uep->ue_top
  106. !                 && top + 2 <= uep->ue_top + uep->ue_size + 1))
  107.               break;
  108.   
  109.           /* If it's the same line we can skip saving it again. */
  110.           if (uep->ue_size == 1 && uep->ue_top == top)
  111.           {
  112.               if (i > 0)
  113.               {
  114. +             /* It's not the last entry: get ue_bot for the last
  115. +              * entry now.  Following deleted/inserted lines go to
  116. +              * the re-used entry. */
  117.               u_getbot();
  118.               curbuf->b_u_synced = FALSE;
  119. +             /* Move the found entry to become the last entry.  The
  120. +              * order of undo/redo doesn't matter for the entries
  121. +              * we move it over, since they don't change the line
  122. +              * count and don't include this line.  It does matter
  123. +              * for the found entry if the line count is changed by
  124. +              * the executed command. */
  125. +             prev_uep->ue_next = uep->ue_next;
  126. +             uep->ue_next = curbuf->b_u_newhead->uh_entry;
  127. +             curbuf->b_u_newhead->uh_entry = uep;
  128.               }
  129.   
  130. !             /* The executed command may change the line count. */
  131.               if (newbot != 0)
  132.               uep->ue_bot = newbot;
  133.               else if (bot > curbuf->b_ml.ml_line_count)
  134.               uep->ue_bot = 0;
  135.               else
  136. ***************
  137. *** 314,319 ****
  138. --- 312,318 ----
  139.               }
  140.               return OK;
  141.           }
  142. +         prev_uep = uep;
  143.           uep = uep->ue_next;
  144.           }
  145.       }
  146. ***************
  147. *** 775,782 ****
  148.       {
  149.       /*
  150.        * the new ue_bot is computed from the number of lines that has been
  151. !      * inserted (0 - deleted) since calling u_save. This is equal to the old
  152. !      * line count subtracted from the current line count.
  153.        */
  154.       extra = curbuf->b_ml.ml_line_count - uep->ue_lcount;
  155.       uep->ue_bot = uep->ue_top + uep->ue_size + 1 + extra;
  156. --- 774,781 ----
  157.       {
  158.       /*
  159.        * the new ue_bot is computed from the number of lines that has been
  160. !      * inserted (0 - deleted) since calling u_save. This is equal to the
  161. !      * old line count subtracted from the current line count.
  162.        */
  163.       extra = curbuf->b_ml.ml_line_count - uep->ue_lcount;
  164.       uep->ue_bot = uep->ue_top + uep->ue_size + 1 + extra;
  165. ***************
  166. *** 788,804 ****
  167.                            * without deleting the current
  168.                            * ones */
  169.       }
  170. -     /* If not the newest entry and lines have been inserted or deleted,
  171. -      * newer entries must have their line numbers adjusted. */
  172. -     if (extra != 0)
  173. -         for (uep = curbuf->b_u_newhead->uh_entry;
  174. -             uep != curbuf->b_u_newhead->uh_getbot_entry;
  175. -             uep = uep->ue_next)
  176. -         {
  177. -         uep->ue_bot -= extra;
  178. -         uep->ue_top -= extra;
  179. -         }
  180.   
  181.       curbuf->b_u_newhead->uh_getbot_entry = NULL;
  182.       }
  183. --- 787,792 ----
  184. *** ../vim61.164/src/version.c    Sat Aug 24 23:19:56 2002
  185. --- src/version.c    Sat Aug 24 23:21:09 2002
  186. ***************
  187. *** 608,609 ****
  188. --- 608,611 ----
  189.   {   /* Add new patch number below this line */
  190. + /**/
  191. +     165,
  192.   /**/
  193.  
  194. -- 
  195.        His head smashed in,  and his heart cut out,
  196.        And his liver removed, and his bowels unplugged,
  197.        And his nostrils raped, and his bottom burned off,
  198.        And his penis split ... and his ...
  199.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  200.  
  201.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  202. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  203. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  204.  \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
  205.