Re: MacVim bug

2 views
Skip to first unread message

björn

unread,
Oct 27, 2007, 3:26:28 PM10/27/07
to vim...@googlegroups.com, vim...@googlegroups.com
Hi,

This problem was brought up on the vim_mac list a while back but it
turns out not to be mac specific so I am posting to the vim_dev list
as well.

On 12/09/2007, Nico Weber <nicola...@gmx.de> wrote:
>
> 1.) :!ls
> 2.) hit space until the "Hit ENTER prompt" appears if necessary
> 3.) Cmd-tab or cmd-` from and to the window where you did this
>
> Results: The prompt is drawn over and over (one additional line per
> focus gained/lost).
>
> This also happens with Carbon Vim, but not with Ubuntu gvim (and of
> course not with the terminal version), so I guess this is a mac
> specific problem. Bjorn, if you fix this, let us know if your patch
> can be adapted to carbon vim as well ;-)

I have finally looked into this problem and found out what causes it.
In ui_focus_change() [ui.c] there is a line like this:

need_redraw |= apply_autocmds(in_focus ? EVENT_FOCUSGAINED
: EVENT_FOCUSLOST, NULL, NULL, FALSE, curbuf);

Now, apply_autocmds() returns 1 if an autocommand was applied which
will set the need_redraw flag and eventually repeat_message() is
called which in turn calls hit_return_msg() [both in message.c] and
the "Press ENTER ..." message is displayed again.

If I run Vim without any autocommands on focus events, then the "Press
ENTER ..." message is displayed only once...otherwise the message is
repeated each time focus is lost or gained (and eventually fills the
entire screen).

How should this be fixed? There is some stuff going on in
hit_return_msg() that I do not understand...the other messages called
in repeat_message() seem to only rewrite the message on the same line
whereas hit_return_msg() starts a new line. I don't dare to just
change hit_return_msg() so that it outputs the message on the same
line every time, since this may break something else as far as I know.
Any ideas?


/Björn

Bram Moolenaar

unread,
Oct 28, 2007, 9:06:35 AM10/28/07
to björn, vim...@googlegroups.com, vim...@googlegroups.com

Bjorn Winckler wrote:

I don't see the sequence of events yet. Why would Vim get more focus
change events?

When a focus autocommand is triggered, Vim may need to redraw, since
it's undefined what the autocommand has done. Imagine the autocommand
does "echo 'focus gained'".

--
CVS sux, men don't like commitment

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

björn

unread,
Oct 28, 2007, 9:27:06 AM10/28/07
to Bram Moolenaar, vim...@googlegroups.com, vim...@googlegroups.com

Try this: start gvim, add autocommands to FocusLost and FocusGained,
then type ":!ls" which will bring up the "Press ENTER or type command
to continue" prompt. Now switch focus to another app and then back to
gvim again and you'll notice that two more "Press ENTER ..." lines
have appeared. Each focus lost/gained event has called
hit_return_msg().

>
> When a focus autocommand is triggered, Vim may need to redraw, since
> it's undefined what the autocommand has done. Imagine the autocommand
> does "echo 'focus gained'".

Ok, so is there nothing to do about this then? How come then
"--more--" prompt only appears once though? (You can repeat the above
procedure with ":digraphs" instead of ":!ls" to see this.)


/Björn

Tony Mechelynck

unread,
Oct 28, 2007, 9:55:42 AM10/28/07
to vim...@googlegroups.com, Bram Moolenaar, vim...@googlegroups.com

I have no FocusGained or FocusLost autocommands, yet if I leave gvim (with
GTK2 GUI) at a Hit-Enter prompt, whenever it regains the focus (after having
lost it to, say, Thunderbird) there is an additional Hit-Enter prompt.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
92. It takes you two hours to check all 14 of your mailboxes.

Tony Mechelynck

unread,
Oct 28, 2007, 9:57:58 AM10/28/07
to vim...@googlegroups.com, Bram Moolenaar, vim...@googlegroups.com
Tony Mechelynck wrote:
[...]

> I have no FocusGained or FocusLost autocommands, yet if I leave gvim (with
> GTK2 GUI) at a Hit-Enter prompt, whenever it regains the focus (after having
> lost it to, say, Thunderbird) there is an additional Hit-Enter prompt.
>
>
> Best regards,
> Tony.

oops, sorry, this time there isn't; and yet, I had seen it previously.

Best regards,
Tony.
--
However, never daunted, I will cope with adversity in my traditional
manner ... sulking and nausea.
-- Tom K. Ryan

Bram Moolenaar

unread,
Oct 28, 2007, 3:47:58 PM10/28/07
to björn, vim...@googlegroups.com, vim...@googlegroups.com

Bjorn Winckler wrote:

Well, you can try this patch. It's difficult to predict if this fails
in some situation.

*** ../vim-7.1.145/src/message.c Thu Sep 13 22:04:30 2007
--- src/message.c Sun Oct 28 20:42:40 2007
***************
*** 2850,2855 ****
--- 2850,2861 ----
}
else if (State == HITRETURN || State == SETWSIZE)
{
+ if (msg_row == Rows - 1)
+ {
+ msg_didout = FALSE;
+ msg_col = 0;
+ msg_clr_eos();
+ }
hit_return_msg();
msg_row = Rows - 1;
}


--
hundred-and-one symptoms of being an internet addict:

52. You ask a plumber how much it would cost to replace the chair in front of
your computer with a toilet.

björn

unread,
Oct 29, 2007, 2:32:24 PM10/29/07
to Bram Moolenaar, vim...@googlegroups.com, vim...@googlegroups.com
On 28/10/2007, Bram Moolenaar <Br...@moolenaar.net> wrote:
>

Thanks, I've applied the patch to the MacVim source so we'll run with
it and see how it goes.


/Björn

Reply all
Reply to author
Forward
0 new messages