|
@@ -341,9 +341,7 @@ def OpenLocationList( focus = False, autoclose = False ):
|
|
|
SetFittingHeightForCurrentWindow()
|
|
|
|
|
|
if autoclose:
|
|
|
- # This autocommand is automatically removed when the location list window is
|
|
|
- # closed.
|
|
|
- vim.command( 'au WinLeave <buffer> q' )
|
|
|
+ AutoCloseOnCurrentBuffer( 'ycmlocation' )
|
|
|
|
|
|
if VariableExists( '#User#YcmLocationOpened' ):
|
|
|
vim.command( 'doautocmd User YcmLocationOpened' )
|
|
@@ -368,9 +366,7 @@ def OpenQuickFixList( focus = False, autoclose = False ):
|
|
|
SetFittingHeightForCurrentWindow()
|
|
|
|
|
|
if autoclose:
|
|
|
- # This autocommand is automatically removed when the quickfix window is
|
|
|
- # closed.
|
|
|
- vim.command( 'au WinLeave <buffer> q' )
|
|
|
+ AutoCloseOnCurrentBuffer( 'ycmquickfix' )
|
|
|
|
|
|
if VariableExists( '#User#YcmQuickFixOpened' ):
|
|
|
vim.command( 'doautocmd User YcmQuickFixOpened' )
|
|
@@ -1238,3 +1234,13 @@ def VimVersionAtLeast( version_string ):
|
|
|
return actual_major_and_minor > matching_major_and_minor
|
|
|
|
|
|
return GetBoolValue( "has( 'patch{0}' )".format( patch ) )
|
|
|
+
|
|
|
+
|
|
|
+def AutoCloseOnCurrentBuffer( name ):
|
|
|
+ """Create an autocommand group with name |name| on the current buffer that
|
|
|
+ automatically closes it when leaving its window."""
|
|
|
+ vim.command( 'augroup {}'.format( name ) )
|
|
|
+ vim.command( 'autocmd! * <buffer>' )
|
|
|
+ vim.command( 'autocmd WinLeave <buffer> '
|
|
|
+ 'if bufnr( "%" ) == expand( "<abuf>" ) | q | endif' )
|
|
|
+ vim.command( 'augroup END' )
|