Xavier de Gaye wrote:
> ===========================================================
> Description:
> ===========================================================
>
> a) The buffer number 3 contains the following three lines
> (the two first lines are 28 chars long, including the newline):
>
> 123456789012345678901234567
> t ={*} 1
> FIN
>
>
> b) Send the following netbeans functions
> (purpose: try to insert a 'u' line in front of the 't' line
> and replace the '*' by a '=' in the 't' line):
>
> 3:remove/91 28 28
> 3:insert/92 28 " u ={*} 1\n"
> 3:insert/93 56 " t ={=} 1\n"
>
>
> c) After completion of the functions, the buffer content is
> (note the '1' standing at first column on line 4):
>
> 123456789012345678901234567
> u ={*} 1
> t ={=} 1
> 1 t ={*} 1
> FIN
>
>
> d) The vim log traces say:
>
> FUN 91: (3) remove 28 28
> FIRST POS: line 2, col 0
> LAST POS: line 2, col 27
> NEW LINE 2: 1 t ={*} 1
> REP 91: <none>
> FUN 92: (3) insert <text>
> REP 92: <none>
> FUN 93: (3) insert <text>
> REP 93: <none>
>
> ===========================================================
>
> I think the problem is that the remove function does not handle the case
> where the 'FIRST POS' and 'LAST POS' include the whole line that must be
> removed entirely. It tries to do a ml_replace() in all the cases where
> 'FIRST POS' and 'LAST POS' are on the same line.
>
> The workaround used currently by clewn is to insert a newline just
> before the line to remove, and to remove the two lines in one shot.
>
> The following patch fixes this problem. However it is not complete as it
> does not handle the case where the section to delete is muli-lines and
> starts with a partial line. The original code does not handle this case
> either.
>
>
> ===========================================================
> 1373a1374
> > linenr_T lnum_of_next;
> 1425a1427,1433
> > /* get the position of the next character after the deleted
> > section */
> > pos = off2pos(buf->bufp, off + count);
> > if (!pos)
> > lnum_of_next = last.lnum;
> > else
> > lnum_of_next = pos->lnum;
> >
> 1427c1435,1436
> < if (first.lnum == last.lnum && first.col != last.col)
> ---
> > if (first.lnum == last.lnum && first.col != last.col
> > && (first.col != 0 || lnum_of_next == last.lnum))
> 1436c1445,1446
> < if (first.lnum < last.lnum)
> ---
> > if (first.lnum < last.lnum
> > || (first.col == 0 && lnum_of_next != last.lnum))
> ===========================================================
Yeah, it appears it's currently only possible to delete characters
within a line or delete 2 lines or more. Quite strange. I wonder how
this ever worked with the actual Netbeans.
I think we should change it to the proper solution:
1. If less than one line, delete characters in one line
2. otherwise:
a. Delete characters in the starting line (if not a whole line)
b. Delete whole lines (if at least one)
c. Delete characters in the ending line (if not a whole line)
--
Don't Panic!
-- The Hitchhiker's Guide to the Galaxy
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---