fmoralesc / vim-tutor-mode

interactive tutorials for vim
84 stars 4 forks source link

`:Tutor 01-vim-beginner 02-vim-intermediate` --> "No tutorials with that name found." #22

Closed ghost closed 9 years ago

ghost commented 9 years ago

:Tutor is being defined this way:

command! -nargs=1 -complete=custom,tutor#TutorCmdComplete Tutor call tutor#TutorCmd(<f-args>)

I don't know much about VimScript, but what I expected is that :Tutor would fail in such a situation, given that -nargs=1 is specified and two arguments were passed. Does <f-args> not honor -nargs=n or something?

fmoralesc commented 9 years ago

No, actually in this case only one argument was passed... I think vim behaves like that because we specify -nargs=1.

What is the use case, btw?

ghost commented 9 years ago

No, actually in this case only one argument was passed

I don't understand... how is 01-vim-beginner 02-vim-intermediate not two arguments? Does Vim behave differently than how things are done in the shell (in this case)?

What is the use case, btw?

:VimTutor has n-args=0, so :VimTutor jsalkdjsalkdjsa prints E488: Trailing characters as expected.

:Tutor has -nargs=1, but :Tutor 01-vim-beginner 02-vim-intermediate instead prints "No tutorials with that name found.", which is incorrect for both arguments. IMO it should either open both tutorials in separate buffers, or just print E488: Trailing characters if there's more than one argument.

fmoralesc commented 9 years ago

I see. No, vim will treat that as a single argument, it won't split on the space.

fmoralesc commented 9 years ago

From :help command-nargs:

    -nargs=1    Exactly one argument is required, it includes spaces 
fmoralesc commented 9 years ago

We should add some extra logic so it catches this scenario. IMHO, it should open the first "argument" and ignore the rest, perhaps displaying a warning to the user. Because, really, does it make sense to open several tutorials at once (unless you are a tutorial writer, in which case you shouldn't be using :Tutor anyway)?

ghost commented 9 years ago

We should add some extra logic so it catches this scenario. IMHO, it should open the first "argument" and ignore the rest, perhaps displaying a warning to the user.

That sounds odd, perhaps just display a warning?

Because, really, does it make sense to open several tutorials at once (unless you are a tutorial writer, in which case you shouldn't be using :Tutor anyway)?

Good point

edit: misquoted you

fmoralesc commented 9 years ago

That sounds odd, perhaps just display a warning?

Yeah, you're right. No point in trying to be too clever.