浏览代码

Avoid skip_post_command_action hack when making Hierarchy request

Boris Staletic 9 月之前
父节点
当前提交
489dcb1583
共有 2 个文件被更改,包括 24 次插入21 次删除
  1. 5 5
      autoload/youcompleteme/hierarchy.vim
  2. 19 16
      python/ycm/youcompleteme.py

+ 5 - 5
autoload/youcompleteme/hierarchy.vim

@@ -44,13 +44,13 @@ function! youcompleteme#hierarchy#StartRequest( kind )
   py3 ycm_state.ResetCurrentHierarchy()
   if a:kind == 'call'
     let lines_and_handles = py3eval(
-      \ 'ycm_state.InitializeCurrentHierarchy( ycm_state.SendCommandRequest( ' .
-      \ '[ "CallHierarchy" ], "", False, 0, 0 ), ' .
+      \ 'ycm_state.InitializeCurrentHierarchy( ycm_state.SendCommandRequestAsync( ' .
+      \ '[ "CallHierarchy" ] ), ' .
       \ 'vim.eval( "a:kind" ) )' )
   else
     let lines_and_handles = py3eval( 
-      \ 'ycm_state.InitializeCurrentHierarchy( ycm_state.SendCommandRequest( ' .
-      \ '[ "TypeHierarchy" ], "", False, 0, 0 ), ' .
+      \ 'ycm_state.InitializeCurrentHierarchy( ycm_state.SendCommandRequestAsync( ' .
+      \ '[ "TypeHierarchy" ] ), ' .
       \ 'vim.eval( "a:kind" ) )' )
   endif
   if len( lines_and_handles )
@@ -63,7 +63,7 @@ endfunction
 
 function! s:MenuFilter( winid, key )
   if a:key == "\<S-Tab>"
-    " ROot changes if we're showing super-tree of a sub-tree of the root
+    " Root changes if we're showing super-tree of a sub-tree of the root
     " (indeicated by the handle being positive)
     let will_change_root = s:lines_and_handles[ s:select - 1 ][ 1 ] > 0
     call popup_close(

+ 19 - 16
python/ycm/youcompleteme.py

@@ -112,7 +112,9 @@ class YouCompleteMe:
     self._current_hierarchy = HierarchyTree()
 
 
-  def InitializeCurrentHierarchy( self, items, kind ):
+  def InitializeCurrentHierarchy( self, request_id, kind ):
+    items = self.GetCommandRequest( request_id ).Response()
+    self.FlushCommandRequest( request_id )
     return self._current_hierarchy.SetRootNode( items, kind )
 
 
@@ -124,13 +126,13 @@ class YouCompleteMe:
 
 
   def _ResolveHierarchyItem( self, handle : int, direction : str ):
-    return SendCommandRequest(
+    request_id = self.SendCommandRequestAsync(
       self._current_hierarchy.ResolveArguments( handle, direction ),
-      '',
-      self._user_options[ 'goto_buffer_command' ],
-      extra_data = None,
-      skip_post_command_action = True
+      silent = False
     )
+    response = self.GetCommandRequest( request_id ).Response()
+    self.FlushCommandRequest( request_id )
+    return response
 
 
   def ShouldResolveItem( self, handle : int, direction : str ):
@@ -424,12 +426,13 @@ class YouCompleteMe:
 
     final_arguments = []
     for argument in arguments:
-      if argument.startswith( 'ft=' ):
-        extra_data[ 'completer_target' ] = argument[ 3: ]
-        continue
-      elif argument.startswith( '--bufnr=' ):
-        extra_data[ 'bufnr' ] = int( argument[ len( '--bufnr=' ): ] )
-        continue
+      if isinstance( argument, str ):
+        if argument.startswith( 'ft=' ):
+          extra_data[ 'completer_target' ] = argument[ 3: ]
+          continue
+        elif argument.startswith( '--bufnr=' ):
+          extra_data[ 'bufnr' ] = int( argument[ len( '--bufnr=' ): ] )
+          continue
 
       final_arguments.append( argument )
 
@@ -456,8 +459,7 @@ class YouCompleteMe:
       final_arguments,
       modifiers,
       self._user_options[ 'goto_buffer_command' ],
-      extra_data,
-      'Hierarchy' in arguments[ 0 ] )
+      extra_data )
 
 
   def GetCommandResponse( self, arguments ):
@@ -469,7 +471,7 @@ class YouCompleteMe:
     return GetCommandResponse( final_arguments, extra_data )
 
 
-  def SendCommandRequestAsync( self, arguments ):
+  def SendCommandRequestAsync( self, arguments, silent = True ):
     final_arguments, extra_data = self._GetCommandRequestArguments(
       arguments,
       False,
@@ -480,7 +482,8 @@ class YouCompleteMe:
     self._next_command_request_id += 1
     self._command_requests[ request_id ] = SendCommandRequestAsync(
       final_arguments,
-      extra_data )
+      extra_data,
+      silent )
     return request_id