Update diagnostic matches only in current window
This commit is contained in:
parent
8216dec954
commit
3151820ff5
@ -129,9 +129,10 @@ class DiagnosticInterface( object ):
|
||||
if not self._user_options[ 'enable_diagnostic_highlighting' ]:
|
||||
return
|
||||
|
||||
with vimsupport.CurrentWindow():
|
||||
for window in vimsupport.GetWindowsForBufferNumber( self._bufnr ):
|
||||
vimsupport.SwitchWindow( window )
|
||||
# Vim doesn't provide a way to update the matches for a different window
|
||||
# than the current one (which is a view of the current buffer).
|
||||
if vimsupport.GetCurrentBufferNumber() != self._bufnr:
|
||||
return
|
||||
|
||||
matches_to_remove = vimsupport.GetDiagnosticMatchesInCurrentWindow()
|
||||
|
||||
|
@ -1047,14 +1047,13 @@ def YouCompleteMe_AsyncDiagnosticUpdate_PerFile_test( ycm,
|
||||
] )
|
||||
] )
|
||||
|
||||
# FIXME: diagnostic matches in windows other than the current one are not
|
||||
# updated.
|
||||
assert_that(
|
||||
test_utils.VIM_MATCHES_FOR_WINDOW,
|
||||
has_entries( {
|
||||
1: contains(
|
||||
VimMatch( 'YcmErrorSection', '\\%1l\\%1c\\_.\\{-}\\%1l\\%1c' )
|
||||
),
|
||||
3: contains(
|
||||
VimMatch( 'YcmErrorSection', '\\%3l\\%3c\\_.\\{-}\\%3l\\%3c' )
|
||||
)
|
||||
} )
|
||||
)
|
||||
|
@ -23,7 +23,6 @@ from __future__ import absolute_import
|
||||
from builtins import * # noqa
|
||||
|
||||
from future.utils import iterkeys
|
||||
import contextlib
|
||||
import vim
|
||||
import os
|
||||
import json
|
||||
@ -1218,49 +1217,6 @@ def BuildRange( start_line, end_line ):
|
||||
}
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def AutocommandEventsIgnored( events = [ 'all' ] ):
|
||||
"""Context manager to perform operations without triggering autocommand
|
||||
events. |events| is a list of events to ignore. By default, all events are
|
||||
ignored."""
|
||||
old_eventignore = vim.options[ 'eventignore' ]
|
||||
ignored_events = {
|
||||
event for event in ToUnicode( old_eventignore ).split( ',' ) if event }
|
||||
ignored_events.update( events )
|
||||
vim.options[ 'eventignore' ] = ','.join( ignored_events )
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
vim.options[ 'eventignore' ] = old_eventignore
|
||||
|
||||
|
||||
def GetPreviousWindowNumber():
|
||||
return GetIntValue( 'winnr("#")' ) - 1
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def CurrentWindow():
|
||||
"""Context manager to perform operations on other windows than the current one
|
||||
without triggering autocommands related to window movement. Use the
|
||||
SwitchWindow function to move to other windows while under the context."""
|
||||
previous_window = vim.windows[ GetPreviousWindowNumber() ]
|
||||
current_window = vim.current.window
|
||||
with AutocommandEventsIgnored( [ 'WinEnter', 'Winleave' ] ):
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
# Ensure <c-w>p still go to the previous window.
|
||||
vim.current.window = previous_window
|
||||
vim.current.window = current_window
|
||||
|
||||
|
||||
def SwitchWindow( window ):
|
||||
"""Move to the window object |window|. This function should be called under
|
||||
the CurrentWindow context if you are going to switch back to the original
|
||||
window."""
|
||||
vim.current.window = window
|
||||
|
||||
|
||||
# Expects version_string in 'MAJOR.MINOR.PATCH' format, e.g. '8.1.278'
|
||||
def VimVersionAtLeast( version_string ):
|
||||
major, minor, patch = ( int( x ) for x in version_string.split( '.' ) )
|
||||
|
Loading…
Reference in New Issue
Block a user