File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed
crates/ide-diagnostics/src/handlers Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ struct State {
3030impl State {
3131 fn generate_new_name ( & mut self , name : & str ) -> ast:: Name {
3232 let name = stdx:: to_camel_case ( name) ;
33- let count = if let Some ( count) = self . names . get ( & name) {
33+ let count = if let Some ( count) = self . names . get_mut ( & name) {
34+ * count += 1 ;
3435 * count
3536 } else {
3637 self . names . insert ( name. clone ( ) , 1 ) ;
@@ -257,6 +258,41 @@ mod tests {
257258 ) ;
258259 }
259260
261+ #[ test]
262+ fn naming ( ) {
263+ check_fix (
264+ r#"
265+ {$0
266+ "user": {
267+ "address": {
268+ "street": "Main St",
269+ "house": 3
270+ },
271+ "email": "example@example.com"
272+ },
273+ "another_user": {
274+ "user": {
275+ "address": {
276+ "street": "Main St",
277+ "house": 3
278+ },
279+ "email": "example@example.com"
280+ }
281+ }
282+ }
283+ "# ,
284+ r#"
285+ struct Address1{ house: i64, street: String }
286+ struct User1{ address: Address1, email: String }
287+ struct AnotherUser1{ user: User1 }
288+ struct Address2{ house: i64, street: String }
289+ struct User2{ address: Address2, email: String }
290+ struct Root1{ another_user: AnotherUser1, user: User2 }
291+
292+ "# ,
293+ ) ;
294+ }
295+
260296 #[ test]
261297 fn arrays ( ) {
262298 check_fix (
You can’t perform that action at this time.
0 commit comments