Ответ на сообщение «Re: [BUG] getchar inside normal always returns an escape», присланное в 23:09:18 22 сентября 2010, Среда, отправитель Bram Moolenaar:
> I'm not sure this is supposed to work. ":normal" feeds characters into
> Vim, using getchar() is problematic there.
According to the `:help :normal' ``{commands} is executed like it is typed.''
(here is probably a typo: should be ``{commands} are executed like if they were
typed''). If this does not work with `getchar()' then it should be mentioned in
documentation.
> The script you give can also be sourced interactively.
What do you mean? I have a List with Lists with two items: user input and my
script output. I want to do something like this:
for [input, output] in tests
execute 'normal '.input
let result=getline(1, line('$'))
if result!=#output
throw "test failed"
endif
endfor
then tests can be done with `so %' just after they are written and without
opening another vim. Without normal command I will have to write some annoying
IPC stuff, the most simple suggestion is to write result into file and check
its
content. If I continue finding such bugs, I will have to write a framework for
functional test of vim plugins using something like pexpect, but now it is
simpler to omit those tests that cannot be easily written in Vimscript.
Текст сообщения:
> ZyX wrote:
> > In the attached script vim prints sequence of ten `27' (that is
> > character number of escape) and a `10', while it is supposed to print
> >
> > 99
> > 104
> > 97
> > 114
> > 115
> > 5
> >
> > (this is ASCII values of characters in string `chars' and a number of
> > symbols).
> >
> > Test command:
> > vim -u NONE -c 'so test-normalesc.vim' -c 'messages' -c 'qa!'
>
> I'm not sure this is supposed to work. ":normal" feeds characters into
> Vim, using getchar() is problematic there.
>
> > PS: It looks like it is impossible to write tests for vim plugins
> > using vimscript, so I will now have to switch to something like
> > pexpect or just stop writing them.
>
> The script you give can also be sourced interactively.
signature.asc
Description: This is a digitally signed message part.
