Hi Bram!

On Do, 25 Okt 2012, Bram Moolenaar wrote:

> 
> Christian Brabandt wrote:
> 
> > On Fri, September 28, 2012 16:04, Marco Hinz wrote:
> > > Hello!
> > >
> > > A member of #vim has experienced a weird behaviour while Vim
> > > scripting. Under certain conditions :echo would only print one line at
> > > max. Thus neither 2x echo nor 1x echo containing a \n would work.
> > >
> > >
> > > Conditions:
> > >
> > > 1) the :echo's are wrapped in an if/endif block
> > >
> > > 2) the if/endif block is the last statement in a function
> > >
> > >
> > > Here is the corresponding stackoverflow.com thread:
> > >
> > > http://stackoverflow.com/questions/12621333/vim-visual-key-input-strange-behaviour
> > 
> > Let me summarize the problem:
> > In the following case, :echo does not seem to work.
> > 
> > noremap <silent> f :call Test()<cr>
> > fun! Test()
> >     call input("OK? ")
> >     if 1
> >         echo "foobar\nfoo"
> >     endif
> > endfun
> > 
> > But it works, if you change the function to:
> > 
> > fun! Test()
> >     call input("OK? ")
> >     if 1
> >         echo "foobar\nfoo"
> >     endif
> >     let a = 1
> > endfun
> > 
> > The problem is, that did_endif is not correctly reset and a recursive
> > call of do_cmdline() changes the global variable did_endif without
> > being reset.
> > 
> > Here is a patch:
> > diff --git a/src/ex_docmd.c b/src/ex_docmd.c
> > --- a/src/ex_docmd.c
> > +++ b/src/ex_docmd.c
> > @@ -1537,6 +1537,8 @@
> >  #endif
> > 
> >      --call_depth;
> > +    if (did_endif)
> > +   did_endif = FALSE;
> >      return retval;
> >  }
> 
> Good catch.  Would it be possible to write a test that fails without the
> fix?

I haven't been able to create a test case. If I redirect the output, it 
will still be visible. 

regards,
Christian
-- 
Hebt ein Tier am Baum ein Bein, weiß man gleich, das ist kein Schwein.

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui