File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -358,7 +358,8 @@ fn extract_and_parse_record_fields(
358358 let info_of_record_fields_in_selection = ele
359359 . fields ( )
360360 . filter_map ( |record_field| {
361- if selection_range. contains_range ( record_field. syntax ( ) . text_range ( ) ) {
361+ let field_range = record_field. syntax ( ) . text_range ( ) ;
362+ if selection_range. intersect ( field_range) . is_some_and ( |rng| !rng. is_empty ( ) ) {
362363 let record_field_info = parse_record_field ( record_field, assist_type) ?;
363364 field_names. push ( record_field_info. fn_name . clone ( ) ) ;
364365 return Some ( record_field_info) ;
@@ -894,6 +895,37 @@ struct Context {
894895 count: usize,
895896}
896897
898+ impl Context {
899+ fn data(&self) -> &Data {
900+ &self.data
901+ }
902+
903+ fn $0count(&self) -> &usize {
904+ &self.count
905+ }
906+ }
907+ "# ,
908+ ) ;
909+ }
910+
911+ #[ test]
912+ fn test_generate_multiple_getters_from_partial_selection ( ) {
913+ check_assist (
914+ generate_getter,
915+ r#"
916+ struct Context {
917+ data$0: Data,
918+ count$0: usize,
919+ other: usize,
920+ }
921+ "# ,
922+ r#"
923+ struct Context {
924+ data: Data,
925+ count: usize,
926+ other: usize,
927+ }
928+
897929impl Context {
898930 fn data(&self) -> &Data {
899931 &self.data
You can’t perform that action at this time.
0 commit comments