e740bac1f6
For instance (`|` represents the cursor): 1. Buffer state: `foo.|bar` 2. A completion candidate of `zoobar` is shown and the user selects it. 3. Buffer state: `foo.zoobar|bar` instead of `foo.zoo|bar` which is what the user wanted. This commit resolves that issue. It could be argued that the user actually wants the final buffer state to be `foo.zoobar|` (the cursor at the end), but that would be much more difficult to implement and is probably not worth doing. Fixes #374.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
#
|
|
# Copyright (C) 2011, 2012 Strahinja Val Markovic <val@markovic.io>
|
|
#
|
|
# This file is part of YouCompleteMe.
|
|
#
|
|
# YouCompleteMe is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# YouCompleteMe is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from mock import MagicMock
|
|
import sys
|
|
|
|
def MockVimModule():
|
|
"""The 'vim' module is something that is only present when running inside the
|
|
Vim Python interpreter, so we replace it with a MagicMock for tests. """
|
|
|
|
def VimEval( value ):
|
|
if value == "g:ycm_min_num_of_chars_for_completion":
|
|
return 0
|
|
return ''
|
|
|
|
vim_mock = MagicMock()
|
|
vim_mock.eval = MagicMock( side_effect = VimEval )
|
|
sys.modules[ 'vim' ] = vim_mock
|
|
return vim_mock
|
|
|