Skip to content

Commit

Permalink
FocusGained FocusLost autocmd missing nomodeline
Browse files Browse the repository at this point in the history
Issue#591: Auto folds close when loosing focus.

The interaction between neovim-qt calling FocusLost and modelines can cause
folds to disappear on their own. This behavior is divergent from nvim.

This fix takes a similar solution/approach to the following:
onivim/oni#575
  • Loading branch information
jgehrig authored and equalsraf committed Oct 4, 2019
1 parent 1eaad0c commit 9875617
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,16 +1351,17 @@ void Shell::closeEvent(QCloseEvent *ev)
void Shell::focusInEvent(QFocusEvent *ev)
{
if (m_attached) {
// See neovim-qt/issues/329 the FocusGained key no longer exists, use autocmd instead
m_nvim->api0()->vim_command("if exists('#FocusGained') | doautocmd FocusGained | endif");
// Issue #329: The <FocusGained> key no longer exists, use autocmd instead.
m_nvim->api0()->vim_command("if exists('#FocusGained') | doautocmd <nomodeline> FocusGained | endif");
}
QWidget::focusInEvent(ev);
}

void Shell::focusOutEvent(QFocusEvent *ev)
{
if (m_attached) {
m_nvim->api0()->vim_command("if exists('#FocusLost') | doautocmd FocusLost | endif");
// Issue #591: Option <nomodeline> prevents unwanted interaction, consistent with nvim.
m_nvim->api0()->vim_command("if exists('#FocusLost') | doautocmd <nomodeline> FocusLost | endif");
}
QWidget::focusOutEvent(ev);
}
Expand Down

0 comments on commit 9875617

Please sign in to comment.