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 {
70
70
pub location_link : bool ,
71
71
pub line_folding_only : bool ,
72
72
pub hierarchical_symbols : bool ,
73
+ pub code_action_literals : bool ,
73
74
}
74
75
75
76
impl Default for Config {
@@ -221,6 +222,11 @@ impl Config {
221
222
{
222
223
self . client_caps . hierarchical_symbols = value
223
224
}
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
+ }
224
230
self . completion . allow_snippets ( false ) ;
225
231
if let Some ( completion) = & caps. completion {
226
232
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(
812
812
}
813
813
}
814
814
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
+ }
815
831
Ok ( Some ( res) )
816
832
}
817
833
Original file line number Diff line number Diff line change @@ -77,7 +77,11 @@ impl<'a> Project<'a> {
77
77
let roots = self . roots . into_iter ( ) . map ( |root| tmp_dir. path ( ) . join ( root) ) . collect ( ) ;
78
78
79
79
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
+ } ,
81
85
with_sysroot : self . with_sysroot ,
82
86
..Config :: default ( )
83
87
} ;
You can’t perform that action at this time.
0 commit comments