puzzling script interaction

0 views
Skip to first unread message

Boyko Bantchev

unread,
Aug 20, 2008, 5:47:44 AM8/20/08
to vim...@googlegroups.com
Hi all,

I've been trying to write an interactive script, where the
input and the output follow in turns -- a REPL. Reduced to
just echoing, it goes like this (get back to Vim by Ctrl-C):

try | while 1
let s:s = input('')
echo "\n".s:s
endw | catch | endt

However, it turns out that the already entered text gets
(partially) erased by the next coming echo command.
My observations show that only as much of the entered text
remains on the ex-input line as is the length of the echo-ed
string that preceded it; in particular, the first entered
line is erased entirely, as there is no echo before it.
Here is a sample session (better read in a non-proportional
font):

" entered abcd
abcd " echo
ef " entered ef
ef " echo
gh " entered ghijk
ghijk " echo
lmnop " entered lmnopqr
lmnopqr " echo
stuv " entered stuv
stuv " echo
...

Could somebody please explain why this happens?
(I can circumvent the problem by printing trailing blanks,
but my question is why an entered text gets erased at all.)

Best regards,
Boyko

Reply all
Reply to author
Forward
0 new messages