On Fri, Aug 6, 2010 at 2:08 AM, Christian J. Robinson <[email protected]> wrote:
> 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").

You are correct.  Is there some good reason the perl methods don't throw
errors somehow for this sort of thing?  Its a tiny bit more convenient I guess
when you want to say "maybe delete" or "maybe set" but it seems not worth
 it to me (obviously I might be biased :).  I could try to make a
patch for this
if it would be welcome.

Britton

-- 
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