Only importing ycm_core in ycmd

I'm not sure, but it seems that loading both ycm_client_support and ycm_core
into the same process is causing random ycmd crashes.
This commit is contained in:
Strahinja Val Markovic 2013-10-28 12:17:18 -07:00
parent b288dce5ba
commit f91790e2ee
2 changed files with 18 additions and 6 deletions

View File

@ -18,8 +18,13 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
import abc
import ycm_client_support
from ycm.utils import ToUtf8IfNeeded, ForceSemanticCompletion
from ycm.utils import ToUtf8IfNeeded, ForceSemanticCompletion, RunningInsideVim
if RunningInsideVim():
from ycm_client_support import FilterAndSortCandidates
else:
from ycm_core import FilterAndSortCandidates
from ycm.completers.completer_utils import TriggersForFiletype
NO_USER_COMMANDS = 'This completer does not define any commands.'
@ -206,8 +211,7 @@ class Completer( object ):
elif 'insertion_text' in candidates[ 0 ]:
sort_property = 'insertion_text'
matches = ycm_client_support.FilterAndSortCandidates(
candidates,
matches = FilterAndSortCandidates( candidates,
sort_property,
ToUtf8IfNeeded( query ) )

View File

@ -62,6 +62,14 @@ def MakeFolderAccessibleToAll( path_to_folder ):
os.chmod( path_to_folder, flags )
def RunningInsideVim():
try:
import vim # NOQA
return True
except ImportError:
return False
def GetUnusedLocalhostPort():
sock = socket.socket()
# This tells the OS to give us any free port in the range [1024 - 65535]