<c-space> again filters the semantic completions

Fixes #576.
This commit is contained in:
Strahinja Val Markovic 2013-10-09 20:20:34 -07:00
parent 98ef568359
commit 8ce07f508c
2 changed files with 43 additions and 6 deletions

View File

@ -153,13 +153,18 @@ class Completer( object ):
not self.ShouldUseNow( request_data ) ):
return []
if ( request_data[ 'query' ] and
self._completions_cache and
candidates = self._GetCandidatesFromSubclass( request_data )
if request_data[ 'query' ]:
candidates = self.FilterAndSortCandidates( candidates,
request_data[ 'query' ] )
return candidates
def _GetCandidatesFromSubclass( self, request_data ):
if ( self._completions_cache and
self._completions_cache.CacheValid( request_data[ 'line_num' ],
request_data[ 'start_column' ] ) ):
return self.FilterAndSortCandidates(
self._completions_cache.raw_completions,
request_data[ 'query' ] )
return self._completions_cache.raw_completions
else:
self._completions_cache = CompletionsCache()
self._completions_cache.raw_completions = self.ComputeCandidatesInner(

View File

@ -25,7 +25,7 @@ from .. import ycmd
from ..responses import BuildCompletionData, UnknownExtraConf
from nose.tools import ok_, eq_, with_setup
from hamcrest import ( assert_that, has_items, has_entry, contains,
contains_string, has_entries )
contains_string, has_entries, contains_inanyorder )
import bottle
bottle.debug( True )
@ -207,6 +207,38 @@ def GetCompletions_ClangCompleter_WorksWhenExtraConfExplicitlyAllowed_test():
CompletionEntryMatcher( 'y' ) ) )
@with_setup( Setup )
def GetCompletions_ClangCompleter_ForceSemantic_OnlyFileteredCompletions_test():
app = TestApp( ycmd.app )
contents = """
int main()
{
int foobar;
int floozar;
int gooboo;
int bleble;
fooar
}
"""
# 0-based line and column!
completion_data = BuildRequest( filepath = '/foo.cpp',
filetype = 'cpp',
force_semantic = True,
contents = contents,
line_num = 8,
column_num = 7,
start_column = 7,
query = 'fooar',
compilation_flags = ['-x', 'c++'] )
results = app.post_json( '/completions', completion_data ).json
assert_that( results,
contains_inanyorder( CompletionEntryMatcher( 'foobar' ),
CompletionEntryMatcher( 'floozar' ) ) )
@with_setup( Setup )
def GetCompletions_ForceSemantic_Works_test():
app = TestApp( ycmd.app )