On Thu, Aug 5, 2010 at 5:53 PM, Britton Kerin <[email protected]> wrote:
> I just figured out that $curbuf->Count() doesn't track the contents
> of $curbuf accross $curbuf->Delete() (and presumably other methods).
>  For example:
>
>    our $curbuf;
>    my @buflines = $curbuf->Get(1 .. $curbuf->Count());
>    print LOG "\...@buflines size before Delete: "....@buflines."\n";
>    print LOG '$curbuf->Count() before Delete: '.$curbuf->Count()."\n";
>    $curbuf->Delete(1 .. $curbuf->Count());
>    print LOG '$curbuf->Count() after Delete: '.$curbuf->Count()."\n";
>
> results in:
>
>   @buflines size before Delete: 86
>   $curbuf->Count() before Delete: 86
>   $curbuf->Count() after Delete: 86

Have you verified that the file actually gets changed with the
$curbuf->Delete() call?  I would be surprised if it did, since your
syntax is invalid.

$curbuf->Delete() only takes one or two integer arguments:  A single
integer deletes the corresponding line;  Two integers deletes a range
of lines.  See ":help perl-Delete".

In other words, this:
    $curbuf->Delete(1 .. $curbuf->Count());
Should be this:
    $curbuf->Delete(1, $curbuf->Count());

When I change your sample of code accordingly, I always get what I
expect ("$curbuf->Count() after delete: 1").

- Christian

-- 
Christian J. Robinson <[email protected]>

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui