Преглед изворни кода

Inlay Hints: clear on insert enter (TODO: alternatively only display strictly in normal mode)

Ben Jackson пре 2 година
родитељ
комит
4d014ea5de
3 измењених фајлова са 18 додато и 5 уклоњено
  1. 6 1
      autoload/youcompleteme.vim
  2. 4 0
      python/ycm/buffer.py
  3. 8 4
      python/ycm/inlay_hints.py

+ 6 - 1
autoload/youcompleteme.vim

@@ -231,7 +231,7 @@ function! youcompleteme#EnableCursorMovedAutocommands()
     autocmd!
     autocmd CursorMoved * call s:OnCursorMovedNormalMode()
     autocmd CursorMovedI * let s:current_cursor_position = getpos( '.' )
-    autocmd InsertEnter * let s:current_cursor_position = getpos( '.' )
+    autocmd InsertEnter * call s:OnInsertEnter()
     autocmd TextChanged * call s:OnTextChangedNormalMode()
     autocmd TextChangedI * call s:OnTextChangedInsertMode( v:false )
     autocmd TextChangedP * call s:OnTextChangedInsertMode( v:true )
@@ -953,6 +953,11 @@ function! s:OnTextChangedInsertMode( popup_is_visible )
 endfunction
 
 
+function! s:OnInsertEnter() abort
+  let s:current_cursor_position = getpos( '.' )
+  py3 ycm_state.CurrentBuffer().ClearInlayHints()
+endfunction
+
 function! s:OnInsertLeave()
   if !s:AllowedToCompleteInCurrentBuffer()
     return

+ 4 - 0
python/ycm/buffer.py

@@ -161,6 +161,10 @@ class Buffer:
     return self._inlay_hints.Update()
 
 
+  def ClearInlayHints( self ):
+    return self._inlay_hints.Clear()
+
+
   def _ChangedTick( self ):
     return vimsupport.GetBufferChangedTick( self._number )
 

+ 8 - 4
python/ycm/inlay_hints.py

@@ -89,6 +89,13 @@ class InlayHints:
   def IsResponseReady( self ):
     return self._request is not None and self._request.Done()
 
+
+  def Clear( self ):
+    for prop_id in self._prop_ids:
+      tp.ClearTextProperties( self._bufnr, prop_id )
+    self._prop_ids.clear()
+
+
   def Update( self ):
     if not self._request:
       # Nothing to update
@@ -106,10 +113,7 @@ class InlayHints:
       self.SendRequest()
       return False # poll again
 
-    for prop_id in self._prop_ids:
-      tp.ClearTextProperties( self._bufnr, prop_id )
-
-    self._prop_ids.clear()
+    self.Clear()
 
     for inlay_hint in inlay_hints:
       if 'kind' not in  inlay_hint: