Browse Source

Start the message poll on buffer visit

Fixes #3540

Always call `s:StartMessagePoll()` in `s:OnBufferEnter()` to make sure
we start the poll after returning from a location list.

The `s:ReceiveMessages()` checks `s:AllowedToCompleteInCurrentBuffer()`
so this change doesn't make the message poll wasteful.
Boris Staletic 5 years ago
parent
commit
f2f4d64678

+ 1 - 1
autoload/youcompleteme.vim

@@ -610,13 +610,13 @@ endfunction
 
 
 function! s:OnBufferEnter()
+  call s:StartMessagePoll()
   if !s:VisitedBufferRequiresReparse()
     return
   endif
 
   call s:SetUpCompleteopt()
   call s:SetCompleteFunc()
-  call s:StartMessagePoll()
 
   exec s:python_command "ycm_state.OnBufferVisit()"
   " Last parse may be outdated because of changes from other buffers. Force a

+ 1 - 3
azure-pipelines.yml

@@ -63,11 +63,9 @@ jobs:
   steps:
   - checkout: self
     submodules: recursive
-  - bash: sudo -H $(PIP) install --upgrade pip setuptools wheel
-    displayName: Upgrade pip
   - bash: sudo -H $(PIP) install -r python/test_requirements.txt
     displayName: Install dependencies
-  - bash: python3 ./install.py --clangd-completer --java-completer
+  - bash: python3 ./install.py --ts-completer --clangd-completer --java-completer
     displayName: Build ycmd
   - script: ./test/run_vim_tests
     displayName: Run vim tests

+ 2 - 2
test/README.md

@@ -14,7 +14,7 @@ your machine.
   `$HOME/YouCompleteMe`
 * Run the following setup:
   * `cd YouCompleteMe`
-  * `python3 install.py --clangd-completer --java-completer`
+  * `python3 install.py --ts-completer --clangd-completer --java-completer`
   * `sudo -H pip3 install -r python/test_requirements.txt`
 * Run the tests:
   * `./test/run_vim_tests`
@@ -31,7 +31,7 @@ in which you can run the tests.
 * Ensure you have at least the Vim vresion in YCM_VIM_VERSION (in
   `test/docker/ci/image/Dockerfile`)
 * Ensure ycmd is compiled ***with python3*** and clangd is enabled
-  `python3 install.py --clangd-completer --java-completer`
+  `python3 install.py --ts-completer --clangd-completer --java-completer`
 * Install the test python deps (`pip install -r python/test_requirements.txt`)
 * Run `./run_vim_tests`
 

+ 29 - 15
test/diagnostics.test.vim

@@ -1,5 +1,10 @@
 function! SetUp()
+  let g:ycm_use_clangd = 1
+  let g:ycm_confirm_extra_conf = 0
+  let g:ycm_auto_trigger = 1
+  let g:ycm_keep_logfiles = 1
   let g:ycm_log_level = 'DEBUG'
+  let g:ycm_always_populate_location_list = 1
   call youcompleteme#test#setup#SetUp()
 endfunction
 
@@ -12,20 +17,29 @@ function! Test_Changing_Filetype_Refreshes_Diagnostics()
         \ '/test/testdata/diagnostics/foo.xml',
         \ { 'native_ft': 0 } )
 
-  function! Check( id ) closure
-    assert_true( pyxeval( 'ycm_state._buffers[ 1 ]._async_diags' ) )
-    assert_equal( 'xml', '&ft' )
-    assert_equal( [], sign_getplaced() )
-    setf typescript
-    assert_equal( 'typescript', '&ft' )
-    assert_false( pyxeval( 'ycm_state._buffers[ 1 ]._async_diags' ) )
-    " Diagnostics are async, so wait for the assert to return 0 for a while.
-    call WaitForAssert( {-> assert_equal( 1, len( sign_getplaced() ) ) }, 10000 )
-    assert_equal( 1, len( sign_getplaced()[ 0 ][ 'signs' ] ) )
-    assert_equal( 1, sign_getplaced()[ 0 ][ 'bufnr' ] )
-    assert_equal( 'YcmError', sign_getplaced()[ 0 ][ 'signs' ][ 0 ][ 'name' ] )
-  endfunction
+  call assert_equal( 'xml', &ft )
+  call assert_true( pyxeval( 'ycm_state._buffers[' . bufnr( '%' ) . ']._async_diags' ) )
+  call assert_equal( [], sign_getplaced() )
+  setf typescript
+  call assert_equal( 'typescript', &ft )
+  call assert_false( pyxeval( 'ycm_state._buffers[' . bufnr( '%' ) . ']._async_diags' ) )
+  " Diagnostics are async, so wait for the assert to return 0 for a while.
+  call WaitForAssert( {-> assert_equal( 1, len( sign_getplaced() ) ) } )
+  call assert_equal( 1, len( sign_getplaced()[ 0 ][ 'signs' ] ) )
+  call assert_equal( 'YcmError', sign_getplaced()[ 0 ][ 'signs' ][ 0 ][ 'name' ] )
+  call assert_false( empty( getloclist( 0 ) ) )
+  %bwipeout!
+endfunction
 
-  call timer_start( 500, funcref( 'Check' ) )
+function! Test_MessagePoll_After_LocationList()
+  call youcompleteme#test#setup#OpenFile( '/test/testdata/diagnostics/foo.cpp', {} )
+
+  setf cpp
+  call assert_equal( 'cpp', &ft )
+  call WaitForAssert( {-> assert_equal( 1, len( sign_getplaced() ) ) } )
+  call setline( 1, '' )
+  doautocmd TextChanged
+  call WaitForAssert( {-> assert_true( empty( sign_getplaced() ) ) }, 10000 )
+  call assert_true( empty( getloclist( 0 ) ) )
   %bwipeout!
-endfunctio
+endfunction

+ 4 - 1
test/docker/ci/image/Dockerfile

@@ -9,7 +9,7 @@ ARG YCM_PYTHON_VERSION=3.5.2
 
 RUN apt-get update && \
   apt-get -y dist-upgrade && \
-  apt-get -y install ca-cacert \
+  apt-get -y --no-install-recommends install ca-cacert \
                      locales \
                      tzdata \
                      language-pack-en \
@@ -21,9 +21,12 @@ RUN apt-get update && \
                      sudo \
                      python-dev \
                      python-pip \
+                     python-setuptools \
                      python3-dev \
                      python3-pip \
+                     python3-setuptools \
                      openjdk-11-jdk-headless \
+                     npm \
                      zlib1g-dev && \
   apt-get -y autoremove
 

+ 1 - 0
test/testdata/diagnostics/foo.cpp

@@ -0,0 +1 @@
+xxx