@@ -34,6 +34,26 @@ pub(crate) const TEST_CONFIG: AssistConfig = AssistConfig {
3434 assist_emit_must_use : false ,
3535 term_search_fuel : 400 ,
3636 term_search_borrowck : true ,
37+ code_action_grouping : true ,
38+ } ;
39+
40+ pub ( crate ) const TEST_CONFIG_NO_GROUPING : AssistConfig = AssistConfig {
41+ snippet_cap : SnippetCap :: new ( true ) ,
42+ allowed : None ,
43+ insert_use : InsertUseConfig {
44+ granularity : ImportGranularity :: Crate ,
45+ prefix_kind : hir:: PrefixKind :: Plain ,
46+ enforce_granularity : true ,
47+ group : true ,
48+ skip_glob_imports : true ,
49+ } ,
50+ prefer_no_std : false ,
51+ prefer_prelude : true ,
52+ prefer_absolute : false ,
53+ assist_emit_must_use : false ,
54+ term_search_fuel : 400 ,
55+ term_search_borrowck : true ,
56+ code_action_grouping : false ,
3757} ;
3858
3959pub ( crate ) const TEST_CONFIG_NO_SNIPPET_CAP : AssistConfig = AssistConfig {
@@ -52,6 +72,7 @@ pub(crate) const TEST_CONFIG_NO_SNIPPET_CAP: AssistConfig = AssistConfig {
5272 assist_emit_must_use : false ,
5373 term_search_fuel : 400 ,
5474 term_search_borrowck : true ,
75+ code_action_grouping : true ,
5576} ;
5677
5778pub ( crate ) const TEST_CONFIG_IMPORT_ONE : AssistConfig = AssistConfig {
@@ -70,6 +91,7 @@ pub(crate) const TEST_CONFIG_IMPORT_ONE: AssistConfig = AssistConfig {
7091 assist_emit_must_use : false ,
7192 term_search_fuel : 400 ,
7293 term_search_borrowck : true ,
94+ code_action_grouping : true ,
7395} ;
7496
7597pub ( crate ) fn with_single_file ( text : & str ) -> ( RootDatabase , EditionedFileId ) {
@@ -346,6 +368,41 @@ fn labels(assists: &[Assist]) -> String {
346368 labels. into_iter ( ) . collect :: < String > ( )
347369}
348370
371+ #[ test]
372+ fn long_groups_are_skipped_under_skip_resolve_strategy ( ) {
373+ let before = r#"
374+ trait SomeTrait {
375+ type T;
376+ fn fn_(arg: u32) -> u32;
377+ fn method_(&mut self) -> bool;
378+ }
379+ struct A;
380+ impl SomeTrait for A {
381+ type T = u32;
382+
383+ fn fn_(arg: u32) -> u32 {
384+ 42
385+ }
386+
387+ fn method_(&mut self) -> bool {
388+ false
389+ }
390+ }
391+ struct B {
392+ a$0 : A,
393+ }
394+ "# ;
395+ let ( before_cursor_pos, before) = extract_offset ( before) ;
396+ let ( db, file_id) = with_single_file ( & before) ;
397+ let frange = FileRange { file_id, range : TextRange :: empty ( before_cursor_pos) } ;
398+ let res = assists ( & db, & TEST_CONFIG , AssistResolveStrategy :: None , frange. into ( ) ) ;
399+ assert ! ( res. iter( ) . map( |a| & a. id) . any( |a| { a. 0 == "generate_delegate_trait" } ) ) ;
400+
401+ let limited =
402+ assists ( & db, & TEST_CONFIG_NO_GROUPING , AssistResolveStrategy :: None , frange. into ( ) ) ;
403+ assert ! ( !limited. iter( ) . map( |a| & a. id) . any( |a| { a. 0 == "generate_delegate_trait" } ) ) ;
404+ }
405+
349406#[ test]
350407fn assist_order_field_struct ( ) {
351408 let before = "struct Foo { $0bar: u32 }" ;
0 commit comments