File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ pub struct ClientCapsConfig {
7070 pub location_link : bool ,
7171 pub line_folding_only : bool ,
7272 pub hierarchical_symbols : bool ,
73+ pub code_action_literals : bool ,
7374}
7475
7576impl Default for Config {
@@ -221,6 +222,11 @@ impl Config {
221222 {
222223 self . client_caps . hierarchical_symbols = value
223224 }
225+ if let Some ( value) =
226+ caps. code_action . as_ref ( ) . and_then ( |it| Some ( it. code_action_literal_support . is_some ( ) ) )
227+ {
228+ self . client_caps . code_action_literals = value;
229+ }
224230 self . completion . allow_snippets ( false ) ;
225231 if let Some ( completion) = & caps. completion {
226232 if let Some ( completion_item) = & completion. completion_item {
Original file line number Diff line number Diff line change @@ -812,6 +812,22 @@ pub fn handle_code_action(
812812 }
813813 }
814814
815+ // If the client only supports commands then filter the list
816+ // and remove and actions that depend on edits.
817+ if !world. config . client_caps . code_action_literals {
818+ res = res
819+ . into_iter ( )
820+ . filter_map ( |it| match it {
821+ cmd @ lsp_types:: CodeActionOrCommand :: Command ( _) => Some ( cmd) ,
822+ lsp_types:: CodeActionOrCommand :: CodeAction ( action) => match action. command {
823+ Some ( cmd) if action. edit . is_none ( ) => {
824+ Some ( lsp_types:: CodeActionOrCommand :: Command ( cmd) )
825+ }
826+ _ => None ,
827+ } ,
828+ } )
829+ . collect ( ) ;
830+ }
815831 Ok ( Some ( res) )
816832}
817833
Original file line number Diff line number Diff line change @@ -77,7 +77,11 @@ impl<'a> Project<'a> {
7777 let roots = self . roots . into_iter ( ) . map ( |root| tmp_dir. path ( ) . join ( root) ) . collect ( ) ;
7878
7979 let mut config = Config {
80- client_caps : ClientCapsConfig { location_link : true , ..Default :: default ( ) } ,
80+ client_caps : ClientCapsConfig {
81+ location_link : true ,
82+ code_action_literals : true ,
83+ ..Default :: default ( )
84+ } ,
8185 with_sysroot : self . with_sysroot ,
8286 ..Config :: default ( )
8387 } ;
You can’t perform that action at this time.
0 commit comments