On 4/28/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

Yakov Lerner wrote:

> I get error 'E16: Invalid range' when I give large count
> (larger than number of lines in current buffer) to the ':10000call X()'
> where function is declared with 'range' attribute.
>
> I think the error is illogical in this case. I think this error must
> not appear when function has 'range' attribute. Count is not alway
> line numbers.
>
> There are many examlpes of builtin commands where count is not
> line numbers. These builtin commands correctly do not give error
> when [count] is larger than num. of buffer lines. For example,
> ':20verb set' correctly does not give error in buffer with <20 lines.
>
> Yakov
>
> Here is testcase
>
> :so x.vim   "see x.vim below
> :5XXX         " this works since 5 is less than lines in buf
> :10000XXX  "gives error  "E16: Invalid range"
>
> ------------ begin file x.vim --------------------
> command! -range XXX  :<count>call XXX()
>
> function! XXX() range
>     echo a:firstline
>     echo a:lastline
> endfu
> ------------ end file x.vim --------------------

If you want to pass a number that is not a line number you need to use
-range=N, where N is the default number.

OK, I added '-range=N' , same thing.
Still doesn't allow large [count]:

 command! -range=1 XXX  :<count>call XXX ()
 function! XXX() range
    echo a:firstline | echo a:lastline
 endfu

"current buffer has 6 lines
:6XXX " works
:7XXX " E16: Invalid range: :7call XXX ()

Yakov

Reply via email to