@@ -1838,23 +1838,19 @@ impl LanguageClient {
18381838 info ! ( "Begin {}" , lsp:: request:: ShowMessageRequest :: METHOD ) ;
18391839 let msg_params: ShowMessageRequestParams = params. clone ( ) . to_lsp ( ) ?;
18401840 let msg_actions = msg_params. actions . unwrap_or_default ( ) ;
1841- let actions: Vec < Value > = msg_actions
1842- . into_iter ( )
1841+ let mut options = Vec :: with_capacity ( msg_actions. len ( ) + 1 ) ;
1842+ options. push ( msg_params. message ) ;
1843+ options. extend ( msg_actions
1844+ . iter ( )
18431845 . enumerate ( )
1844- . map ( |( i, item) | Value :: String ( format ! ( "{}) {}" , i + 1 , item. title) ) )
1845- . collect ( ) ;
1846- let mut options: Vec < Value > = Vec :: with_capacity ( actions. len ( ) + 1 ) ;
1847- options. push ( Value :: String ( msg_params. message ) ) ;
1848- options. extend ( actions) ;
1846+ . map ( |( i, item) | format ! ( "{}) {}" , i + 1 , item. title) ) ) ;
18491847
18501848 let mut v = Value :: Null ;
1851- let result: Option < i64 > = self . vim ( ) ?. rpcclient . call ( "s:inputlist" , options) ?;
1852- if let Some ( answer) = result {
1853- let raw_actions: Vec < Value > = try_get ( "actions" , & params) ?. unwrap_or_default ( ) ;
1854- if let Some ( action) = raw_actions. get ( ( answer - 1 ) as usize ) {
1855- v = action. clone ( ) ;
1856- }
1849+ let index: Option < usize > = self . vim ( ) ?. rpcclient . call ( "s:inputlist" , options) ?;
1850+ if let Some ( index) = index {
1851+ v = serde_json:: to_value ( msg_actions. get ( index - 1 ) ) ?;
18571852 }
1853+
18581854 info ! ( "End {}" , lsp:: request:: ShowMessageRequest :: METHOD ) ;
18591855 Ok ( v)
18601856 }
0 commit comments