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

If you look closer you can see you get a different error message now.

Sorry, I should have mentioned in the previous message that the ":call"
command only accepts valid line numbers.  If you want to pass a count to
a function use a function argument.

-- 
Any sufficiently advanced technology is indistinguishable from magic.
                                        Arthur C. Clarke
Any sufficiently advanced bug is indistinguishable from a feature.
                                        Rich Kulawiec

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

Reply via email to