macvim
macvim copied to clipboard
Newly created gvim window not focused, existing gvim window is focused instead
Describe the bug
When creating a new gvim window via terminal gvim
command, sometimes the new pop-up window doesn't gain focus, instead, the pre-existing gvim window is focused. This causes minor annoyance because user would intuitively think he/she is typing into the new window without checking.
I suspect it has something to do with multi-monitor environment and each monitor has a separate desktop number. Sometimes I typed gvim
in the terminal and the new gvim window was opened in another monitor. And in that case often the wrong window was focused. Maybe macvim will focus window instance on the desktop with lowest index number?
Not sure if this is related to #83.
I didn't find out the pattern to reliably reproduce the behavior yet.
To Reproduce Detailed steps to reproduce the behavior:
- Open a terminal.
- Type
gvim
. - A new gvim instance popped up.
- But the original gvim instance is focused.
Expected behavior The new gvim instance is focused.
Environment (please complete the following information):
- Vim version: 8.2.2164
- OS: macOS 11.1
- Terminal: iTerm2
Sorry, but I'm trying to find a way to repro from your description and can't quite figure out how.
I guess this issue only happens when you are using multiple monitors? When this issue happens how many MacVim windows do you have opened and on what monitor? Does the new instance show up at the same monitor or only on a monitor with no existing Vim instance opened (I think it's supposed to always pick a monitor with an existing instance)? Are you using fullscreen mode?
If you have multiple monitors, if you go to System Preferences → Mission Control, do you see "Displays have separate Spaces" checked?
Also, can you let me know what this commands says? defaults read org.vim.MacVim | grep MM
.
Hi @ychin , thanks for replying. No worries, I can't figure out how to reproduce it either 😅 . It just happens (sometimes).
Regarding to your questions:
I guess this issue only happens when you are using multiple monitors?
Yes, I think it happens only with multi-monitor setup.
When this issue happens how many MacVim windows do you have opened and on what monitor? Does the new instance show up at the same monitor or only on a monitor with no existing Vim instance opened (I think it's supposed to always pick a monitor with an existing instance)? Are you using fullscreen mode?
I have 3 monitors (1 MBP internal + 2 external monitors), with one Desktop on each.
- When the focusing issue happened, I had one open gvim window on Desktop 1 (monitor 1), and iTerm2 window also on Desktop 1.
- I typed
gvim
in terminal, a new gvim window popped up on Desktop 2 (monitor 2), but the focus was on the original gvim window on Desktop 1.
And I'm not using fullscreen mode for any window.
do you see "Displays have separate Spaces" checked?
Yes, it's checked.
Output of defaults read org.vim.MacVim | grep MM
:
MMAutosaveColumns = 191;
MMAutosaveRows = 53;
MMTopLeftPoint = "{-3, 1055}";
I saw this issue with multiple monitors with other apps as well including Safari