@@ -41,15 +41,33 @@ function! youcompleteme#hierarchy#StartRequest( kind )
4141 endif
4242
4343 call youcompleteme#symbol#InitSymbolProperties ()
44- py3 ycm_state.ResetCurrentHierarchy ()
4544 py3 from ycm.client.command_request import GetRawCommandResponse
45+
46+ if a: kind == ' resume'
47+ call s: SetUpMenu ()
48+ return
49+ endif
50+
51+ if a: kind == ' addcall'
52+ let handle = s: lines_and_handles [ s: select - 1 ][ 1 ]
53+ let lines_and_handles = py3eval (
54+ \ ' ycm_state.AddCurrentHierarchy( ' .
55+ \ ' vimsupport.GetIntValue( "handle" ), ' .
56+ \ ' GetRawCommandResponse( ' .
57+ \ ' [ "CallHierarchy" ], False ))' )
58+ let s: lines_and_handles = lines_and_handles
59+ call s: SetUpMenu ()
60+ return
61+ endif
62+
63+ py3 ycm_state.ResetCurrentHierarchy ()
4664 if a: kind == ' call'
4765 let lines_and_handles = py3eval (
4866 \ ' ycm_state.InitializeCurrentHierarchy( GetRawCommandResponse( ' .
4967 \ ' [ "CallHierarchy" ], False ), ' .
5068 \ ' vim.eval( "a:kind" ) )' )
5169 else
52- let lines_and_handles = py3eval (
70+ let lines_and_handles = py3eval (
5371 \ ' ycm_state.InitializeCurrentHierarchy( GetRawCommandResponse( ' .
5472 \ ' [ "TypeHierarchy" ], False ), ' .
5573 \ ' vim.eval( "a:kind" ) )' )
@@ -62,7 +80,22 @@ function! youcompleteme#hierarchy#StartRequest( kind )
6280 endif
6381endfunction
6482
83+ function ! s: RedrawMenu ()
84+ let pos = popup_getpos ( s: popup_id )
85+ call win_execute ( s: popup_id ,
86+ \ ' call cursor( [' . string ( s: select ) . ' , 1 ] )' )
87+ call win_execute ( s: popup_id ,
88+ \ ' set cursorline cursorlineopt&' )
89+ if s: select < pos.firstline
90+ call win_execute ( s: popup_id , " normal z\<CR> " )
91+ endif
92+ if s: select >= (pos.firstline + pos.core_height )
93+ call win_execute ( s: popup_id , ' :normal z-' )
94+ endif
95+ endfunction
96+
6597function ! s: MenuFilter ( winid, key )
98+ let pos = popup_getpos ( s: popup_id )
6699 if a: key == " \<S-Tab> "
67100 " Root changes if we're showing super-tree of a sub-tree of the root
68101 " (indicated by the handle being positive)
@@ -81,6 +114,20 @@ function! s:MenuFilter( winid, key )
81114 \ [ s: select - 1 , ' resolve_down' , will_change_root ] )
82115 return 1
83116 endif
117+ if a: key == " c"
118+ let will_change_root = 0
119+ call popup_close (
120+ \ s: popup_id ,
121+ \ [ s: select - 1 , ' resolve_close' , will_change_root ] )
122+ return 1
123+ endif
124+ if a: key == " d"
125+ let will_change_root = 0
126+ call popup_close (
127+ \ s: popup_id ,
128+ \ [ s: select - 1 , ' resolve_remove' , will_change_root ] )
129+ return 1
130+ endif
84131 if a: key == " \<CR> "
85132 call popup_close ( s: popup_id , [ s: select - 1 , ' jump' , v: none ] )
86133 return 1
@@ -90,21 +137,31 @@ function! s:MenuFilter( winid, key )
90137 if s: select < 1
91138 let s: select = 1
92139 endif
93- call win_execute ( s: popup_id ,
94- \ ' call cursor( [' . string ( s: select ) . ' , 1 ] )' )
95- call win_execute ( s: popup_id ,
96- \ ' set cursorline cursorlineopt&' )
140+ call s: RedrawMenu ()
141+ return 1
142+ endif
143+ if a: key == " \<PageUp> " || a: key == " \<kPageUp> "
144+ let s: select -= pos.core_height
145+ if s: select < 1
146+ let s: select = 1
147+ endif
148+ call s: RedrawMenu ()
97149 return 1
98150 endif
99151 if a: key == " \<Down> " || a: key == " \<C-n> " || a: key == " \<C-j> " || a: key == " j"
100152 let s: select += 1
101153 if s: select > len ( s: lines_and_handles )
102154 let s: select = len ( s: lines_and_handles )
103155 endif
104- call win_execute ( s: popup_id ,
105- \ ' call cursor( [' . string ( s: select ) . ' , 1 ] )' )
106- call win_execute ( s: popup_id ,
107- \ ' set cursorline cursorlineopt&' )
156+ call s: RedrawMenu ()
157+ return 1
158+ endif
159+ if a: key == " \<PageDown> " || a: key == " \<kPageDown> "
160+ let s: select += pos.core_height
161+ if s: select > len ( s: lines_and_handles )
162+ let s: select = len ( s: lines_and_handles )
163+ endif
164+ call s: RedrawMenu ()
108165 return 1
109166 endif
110167 if index ( s: ingored_keys , a: key ) >= 0
@@ -125,14 +182,15 @@ function! s:MenuCallback( winid, result )
125182 call s: ResolveItem ( selection , ' down' , a: result [ 2 ] )
126183 elseif operation == ' resolve_up'
127184 call s: ResolveItem ( selection , ' up' , a: result [ 2 ] )
185+ elseif operation == ' resolve_close'
186+ call s: ResolveItem ( selection , ' close' , a: result [ 2 ] )
187+ elseif operation == ' resolve_remove'
188+ call s: ResolveItem ( selection , ' remove' , a: result [ 2 ] )
128189 else
129190 if operation == ' jump'
130191 let handle = s: lines_and_handles [ selection ][ 1 ]
131192 py3 ycm_state.JumpToHierarchyItem ( vimsupport.GetIntValue ( " handle" ) )
132193 endif
133- py3 ycm_state.ResetCurrentHierarchy ()
134- let s: kind = ' '
135- let s: select = 1
136194 endif
137195endfunction
138196
@@ -208,6 +266,7 @@ function! s:SetUpMenu()
208266 \ . " \t "
209267 \ .. trunc_desc
210268 call add ( menu_lines, { ' text' : line , ' props' : props } )
269+
211270 endfor
212271 call win_execute ( s: popup_id ,
213272 \ ' setlocal tabstop=' . tabstop )
0 commit comments