Loading ...
Sorry, an error occurred while loading the content.

Patch 6.0.011

Expand Messages
  • Bram Moolenaar
    Patch 6.0.011 Problem: Python: After replacing or deleting lines get an ml_get error. (Leo Lipelis) Solution: Adjust the cursor position for deleted or
    Message 1 of 1 , Sep 30, 2001
    • 0 Attachment
      Patch 6.0.011
      Problem: Python: After replacing or deleting lines get an ml_get error.
      (Leo Lipelis)
      Solution: Adjust the cursor position for deleted or added lines.
      Files: src/if_python.c


      *** ../vim60.10/src/if_python.c Fri Aug 24 21:30:54 2001
      --- src/if_python.c Sat Sep 29 20:40:30 2001
      ***************
      *** 2116,2121 ****
      --- 2116,2148 ----
      return list;
      }

      + /*
      + * Check if deleting lines made the cursor position invalid.
      + * Changed the lines from "lo" to "hi" and added "extra" lines (negative if
      + * deleted).
      + */
      + static void
      + py_fix_cursor(int lo, int hi, int extra)
      + {
      + if (curwin->w_cursor.lnum >= lo)
      + {
      + /* Adjust the cursor position if it's in/after the changed
      + * lines. */
      + if (curwin->w_cursor.lnum >= hi)
      + {
      + curwin->w_cursor.lnum += extra;
      + check_cursor_col();
      + }
      + else if (extra < 0)
      + {
      + curwin->w_cursor.lnum = lo;
      + check_cursor();
      + }
      + changed_cline_bef_curs();
      + }
      + invalidate_botline();
      + }
      +
      /* Replace a line in the specified buffer. The line number is
      * in Vim format (1-based). The replacement line is given as
      * a Python string object. The object is checked for validity
      ***************
      *** 2145,2151 ****
      --- 2172,2182 ----
      else if (ml_delete((linenr_T)n, FALSE) == FAIL)
      PyErr_SetVim(_("cannot delete line"));
      else
      + {
      deleted_lines_mark((linenr_T)n, 1L);
      + if (buf == curwin->w_buffer)
      + py_fix_cursor(n, n + 1, -1);
      + }

      curbuf = savebuf;

      ***************
      *** 2234,2239 ****
      --- 2265,2273 ----
      }
      }
      deleted_lines_mark((linenr_T)lo, (long)i);
      +
      + if (buf == curwin->w_buffer)
      + py_fix_cursor(lo, hi, -n);
      }

      curbuf = savebuf;
      ***************
      *** 2353,2358 ****
      --- 2387,2395 ----
      mark_adjust((linenr_T)lo, (linenr_T)(hi - 1),
      (long)MAXLNUM, (long)extra);
      changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
      +
      + if (buf == curwin->w_buffer)
      + py_fix_cursor(lo, hi, extra);

      curbuf = savebuf;

      *** ../vim60.10/src/version.c Sun Sep 30 10:53:07 2001
      --- src/version.c Sun Sep 30 10:54:20 2001
      ***************
      *** 608,609 ****
      --- 608,611 ----
      { /* Add new patch number below this line */
      + /**/
      + 11,
      /**/

      --
      Time is money. Especially if you make clocks.

      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
      ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
      \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
    Your message has been successfully submitted and would be delivered to recipients shortly.