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.0.196 < prev    next >
Encoding:
Internet Message Format  |  2002-02-06  |  10.0 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.196
  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.0.196
  11. Problem:    When 'virtualedit' is set, 'selection' is "exclusive" and visually
  12.         selecting part of a tab at the start of a line, "x" joins it with
  13.         the previous line.  Also, when the selection spans more than one
  14.         line the whole tab is deleted.
  15. Solution:   Take coladd into account when adjusting for 'selection' being
  16.         "exclusive".  Also expand a tab into spaces when deleting more
  17.         than one line.
  18. Files:        src/normal.c, src/ops.c
  19.  
  20.  
  21. *** ../vim60.195/src/normal.c    Wed Feb  6 17:47:31 2002
  22. --- src/normal.c    Thu Feb  7 11:53:11 2002
  23. ***************
  24. *** 5147,5156 ****
  25.       /* In virtual mode when off the edge of a line and an operator
  26.        * is pending (whew!) keep the cursor where it is.
  27.        * Otherwise, send it to the end of the line. */
  28. !     if (!virtual_active() || gchar_cursor() != NUL ||
  29. !         cap->oap->op_type == OP_NOP)
  30.   #endif
  31. !     curwin->w_curswant = MAXCOL;    /* so we stay at the end */
  32.       if (cursor_down((long)(cap->count1 - 1),
  33.                        cap->oap->op_type == OP_NOP) == FAIL)
  34.       clearopbeep(cap->oap);
  35. --- 5147,5156 ----
  36.       /* In virtual mode when off the edge of a line and an operator
  37.        * is pending (whew!) keep the cursor where it is.
  38.        * Otherwise, send it to the end of the line. */
  39. !     if (!virtual_active() || gchar_cursor() != NUL
  40. !                            || cap->oap->op_type == OP_NOP)
  41.   #endif
  42. !     curwin->w_curswant = MAXCOL;    /* so we stay at the end */
  43.       if (cursor_down((long)(cap->count1 - 1),
  44.                        cap->oap->op_type == OP_NOP) == FAIL)
  45.       clearopbeep(cap->oap);
  46. ***************
  47. *** 6563,6571 ****
  48.   #ifdef FEAT_VISUAL
  49.       pos_T    tpos;
  50.   #endif
  51. - #ifdef FEAT_VIRTUALEDIT
  52. -     int        coladd;
  53. - #endif
  54.       int        i;
  55.       int        flag = FALSE;
  56.   
  57. --- 6563,6568 ----
  58. ***************
  59. *** 6627,6636 ****
  60.           curbuf->b_visual_end = curwin->w_cursor;
  61.           curwin->w_cursor = curbuf->b_visual_start;
  62.           curbuf->b_visual_start = VIsual;
  63. - #ifdef FEAT_VIRTUALEDIT
  64. -         coladd = tpos.coladd;
  65. - #endif
  66.           }
  67.           else
  68.           {
  69. --- 6624,6629 ----
  70. ***************
  71. *** 6638,6646 ****
  72.           curwin->w_curswant = curbuf->b_visual_curswant;
  73.           tpos = curbuf->b_visual_end;
  74.           curwin->w_cursor = curbuf->b_visual_start;
  75. - #ifdef FEAT_VIRTUALEDIT
  76. -         coladd = curbuf->b_visual_end.coladd;
  77. - #endif
  78.           }
  79.   
  80.           VIsual_active = TRUE;
  81. --- 6631,6636 ----
  82. ***************
  83. *** 6651,6659 ****
  84.           check_cursor();
  85.           VIsual = curwin->w_cursor;
  86.           curwin->w_cursor = tpos;
  87. - #ifdef FEAT_VIRTUALEDIT
  88. -         curwin->w_cursor.coladd = coladd;
  89. - #endif
  90.           check_cursor();
  91.           update_topline();
  92.           /*
  93. --- 6641,6646 ----
  94. ***************
  95. *** 7425,7430 ****
  96. --- 7412,7422 ----
  97.           pp = &curwin->w_cursor;
  98.       else
  99.           pp = &VIsual;
  100. + #ifdef FEAT_VIRTUALEDIT
  101. +     if (pp->coladd > 0)
  102. +         --pp->coladd;
  103. +     else
  104. + #endif
  105.       if (pp->col > 0)
  106.           --pp->col;
  107.       else if (pp->lnum > 1)
  108. *** ../vim60.195/src/ops.c    Tue Feb  5 21:56:42 2002
  109. --- src/ops.c    Thu Feb  7 12:18:11 2002
  110. ***************
  111. *** 1621,1724 ****
  112.           u_clearline();    /* "U" command not possible after "dd" */
  113.       }
  114.       }
  115. !     else if (oap->line_count == 1)    /* delete characters within one line */
  116.       {
  117. !     if (u_save_cursor() == FAIL)
  118.           return FAIL;
  119. -     /* if 'cpoptions' contains '$', display '$' at end of change */
  120. -     if (       vim_strchr(p_cpo, CPO_DOLLAR) != NULL
  121. -         && oap->op_type == OP_CHANGE
  122. -         && oap->end.lnum == curwin->w_cursor.lnum
  123. - #ifdef FEAT_VISUAL
  124. -         && !oap->is_VIsual
  125. - #endif
  126. -         )
  127. -         display_dollar(oap->end.col - !oap->inclusive);
  128.   
  129. -     n = oap->end.col - oap->start.col + 1 - !oap->inclusive;
  130.   #ifdef FEAT_VIRTUALEDIT
  131.       if (virtual_active())
  132.       {
  133. !         /* fix up things for virtualedit-delete:
  134. !          * make sure the coladds are in the right order, and
  135. !          * break the tabs which are going to get in our way
  136. !          */
  137. !         char_u    *curline = ml_get_curline();
  138. !         int        oldcol = getviscol();
  139. !         int        len;
  140. !         int        endcol;
  141.   
  142. !         if (oap->start.col == oap->end.col
  143. !             && oap->end.coladd < oap->start.coladd)
  144.           {
  145. !         colnr_T tmp = oap->start.coladd;
  146. !         oap->start.coladd = oap->end.coladd;
  147. !         oap->end.coladd = tmp;
  148. !         curwin->w_cursor.coladd = oap->start.coladd;
  149. !         }
  150. !         if (curline[oap->start.col] == '\t')
  151. !         {
  152. !         endcol = getviscol2(oap->end.col, oap->end.coladd);
  153.           coladvance_force(getviscol2(oap->start.col, oap->start.coladd));
  154. !         oap->start.col = curwin->w_cursor.col;
  155. !         oap->start.coladd = 0;
  156. !         coladvance(endcol);
  157. !         oap->end.col = curwin->w_cursor.col;
  158. !         oap->end.coladd = curwin->w_cursor.coladd;
  159. !         coladvance(oldcol);
  160. !         curline = ml_get_curline();
  161.           }
  162.   
  163. !         if (curline[oap->end.col] == '\t')
  164.           {
  165.           coladvance_force(getviscol2(oap->end.col, oap->end.coladd));
  166. !         oap->end.col = curwin->w_cursor.col;
  167. !         oap->end.coladd = 0;
  168. !         coladvance(oldcol);
  169. !         curline = ml_get_curline();
  170.           }
  171.   
  172.           n = oap->end.col - oap->start.col + 1 - !oap->inclusive;
  173. -         len = (int)STRLEN(curline);
  174.   
  175. !         if (oap->end.coladd != 0 && (int)oap->end.col >= len - 1
  176. !             && !(oap->start.coladd && (int)oap->end.col >= len - 1))
  177. !         n++;
  178. !         /* Delete at least one character (e.g, when on a control char). */
  179. !         if (n == 0 && oap->start.coladd != oap->end.coladd)
  180. !         n = 1;
  181. !         /* When deleted a char in the line, reset coladd. */
  182. !         if (gchar_cursor() != NUL)
  183. !         curwin->w_cursor.coladd = 0;
  184. !     }
  185.   #endif
  186. !     (void)del_bytes((long)n, restart_edit == NUL);
  187. !     }
  188. !     else                /* delete characters between lines */
  189. !     {
  190. !     if (u_save_cursor() == FAIL)    /* save first line for undo */
  191. !         return FAIL;
  192. !     truncate_line(TRUE);        /* delete from cursor to end of line */
  193. !     oap->start = curwin->w_cursor;    /* remember curwin->w_cursor */
  194. !     ++curwin->w_cursor.lnum;
  195. !                     /* includes save for undo */
  196. !     del_lines((long)(oap->line_count - 2), TRUE);
  197.   
  198. !     if (u_save_cursor() == FAIL)    /* save last line for undo */
  199. !         return FAIL;
  200. !     u_clearline();            /* "U" should not be possible now */
  201. !     /* delete from start of line until op_end */
  202. !     curwin->w_cursor.col = 0;
  203. !     (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
  204.                                restart_edit == NUL);
  205. !     curwin->w_cursor = oap->start;    /* restore curwin->w_cursor */
  206.   
  207. !     (void)do_join(FALSE);
  208.       }
  209.   
  210.       msgmore(curbuf->b_ml.ml_line_count - old_lcount);
  211. --- 1621,1720 ----
  212.           u_clearline();    /* "U" command not possible after "dd" */
  213.       }
  214.       }
  215. !     else
  216.       {
  217. !     if (u_save_cursor() == FAIL)    /* save first line for undo */
  218.           return FAIL;
  219.   
  220.   #ifdef FEAT_VIRTUALEDIT
  221.       if (virtual_active())
  222.       {
  223. !         int        endcol = 0;
  224.   
  225. !         /* For virtualedit: break the tabs that are partly included. */
  226. !         if (gchar_pos(&oap->start) == '\t')
  227.           {
  228. !         if (oap->line_count == 1)
  229. !             endcol = getviscol2(oap->end.col, oap->end.coladd);
  230.           coladvance_force(getviscol2(oap->start.col, oap->start.coladd));
  231. !         oap->start = curwin->w_cursor;
  232. !         if (oap->line_count == 1)
  233. !         {
  234. !             coladvance(endcol);
  235. !             oap->end.col = curwin->w_cursor.col;
  236. !             oap->end.coladd = curwin->w_cursor.coladd;
  237. !             curwin->w_cursor = oap->start;
  238. !         }
  239.           }
  240.   
  241. !         if (gchar_pos(&oap->end) == '\t')
  242.           {
  243. +         curwin->w_cursor = oap->end;
  244.           coladvance_force(getviscol2(oap->end.col, oap->end.coladd));
  245. !         oap->end = curwin->w_cursor;
  246. !         curwin->w_cursor = oap->start;
  247.           }
  248. +     }
  249. + #endif
  250. +     if (oap->line_count == 1)    /* delete characters within one line */
  251. +     {
  252. +         /* if 'cpoptions' contains '$', display '$' at end of change */
  253. +         if (       vim_strchr(p_cpo, CPO_DOLLAR) != NULL
  254. +             && oap->op_type == OP_CHANGE
  255. +             && oap->end.lnum == curwin->w_cursor.lnum
  256. + #ifdef FEAT_VISUAL
  257. +             && !oap->is_VIsual
  258. + #endif
  259. +             )
  260. +         display_dollar(oap->end.col - !oap->inclusive);
  261.   
  262.           n = oap->end.col - oap->start.col + 1 - !oap->inclusive;
  263.   
  264. ! #ifdef FEAT_VIRTUALEDIT
  265. !         if (virtual_active())
  266. !         {
  267. !         /* fix up things for virtualedit-delete:
  268. !          * break the tabs which are going to get in our way
  269. !          */
  270. !         char_u        *curline = ml_get_curline();
  271. !         int        len = (int)STRLEN(curline);
  272. !         if (oap->end.coladd != 0
  273. !             && (int)oap->end.col >= len - 1
  274. !             && !(oap->start.coladd && (int)oap->end.col >= len - 1))
  275. !             n++;
  276. !         /* Delete at least one char (e.g, when on a control char). */
  277. !         if (n == 0 && oap->start.coladd != oap->end.coladd)
  278. !             n = 1;
  279. !         /* When deleted a char in the line, reset coladd. */
  280. !         if (gchar_cursor() != NUL)
  281. !             curwin->w_cursor.coladd = 0;
  282. !         }
  283.   #endif
  284. !         (void)del_bytes((long)n, restart_edit == NUL);
  285. !     }
  286. !     else                /* delete characters between lines */
  287. !     {
  288. !         truncate_line(TRUE);    /* delete from cursor to end of line */
  289.   
  290. !         oap->start = curwin->w_cursor;    /* remember curwin->w_cursor */
  291. !         ++curwin->w_cursor.lnum;
  292. !                         /* includes save for undo */
  293. !         del_lines((long)(oap->line_count - 2), TRUE);
  294. !         if (u_save_cursor() == FAIL)    /* save last line for undo */
  295. !         return FAIL;
  296. !         u_clearline();            /* "U" not possible now */
  297. !         /* delete from start of line until op_end */
  298. !         curwin->w_cursor.col = 0;
  299. !         (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
  300.                                restart_edit == NUL);
  301. !         curwin->w_cursor = oap->start;    /* restore curwin->w_cursor */
  302.   
  303. !         (void)do_join(FALSE);
  304. !     }
  305.       }
  306.   
  307.       msgmore(curbuf->b_ml.ml_line_count - old_lcount);
  308. *** ../vim60.195/src/version.c    Thu Feb  7 11:37:45 2002
  309. --- src/version.c    Thu Feb  7 12:22:19 2002
  310. ***************
  311. *** 608,609 ****
  312. --- 608,611 ----
  313.   {   /* Add new patch number below this line */
  314. + /**/
  315. +     196,
  316.   /**/
  317.  
  318. -- 
  319. hundred-and-one symptoms of being an internet addict:
  320. 261. You find diskettes in your pockets when doing laundry.
  321.  
  322.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  323. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  324.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  325.