mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 03:54:42 +00:00 
			
		
		
		
	fix: Fix ref text edit for binding mode hints
				
					
				
			This commit is contained in:
		
							parent
							
								
									9923b0085c
								
							
						
					
					
						commit
						720e727a9d
					
				
					 1 changed files with 27 additions and 2 deletions
				
			
		|  | @ -106,7 +106,7 @@ pub(super) fn hints( | ||||||
|                     InlayHintPosition::Before => h.range.start(), |                     InlayHintPosition::Before => h.range.start(), | ||||||
|                     InlayHintPosition::After => h.range.end(), |                     InlayHintPosition::After => h.range.end(), | ||||||
|                 }, |                 }, | ||||||
|                 h.label.parts.iter().map(|p| &*p.text).collect(), |                 h.label.parts.iter().map(|p| &*p.text).chain(h.pad_right.then_some(" ")).collect(), | ||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
|         let edit = edit.finish(); |         let edit = edit.finish(); | ||||||
|  | @ -118,8 +118,10 @@ pub(super) fn hints( | ||||||
| 
 | 
 | ||||||
| #[cfg(test)] | #[cfg(test)] | ||||||
| mod tests { | mod tests { | ||||||
|  |     use expect_test::expect; | ||||||
|  | 
 | ||||||
|     use crate::{ |     use crate::{ | ||||||
|         inlay_hints::tests::{check_with_config, DISABLED_CONFIG}, |         inlay_hints::tests::{check_edit, check_with_config, DISABLED_CONFIG}, | ||||||
|         InlayHintsConfig, |         InlayHintsConfig, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -194,4 +196,27 @@ fn foo(s @ Struct { field, .. }: &Struct) {} | ||||||
| "#,
 | "#,
 | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     #[test] | ||||||
|  |     fn edits() { | ||||||
|  |         check_edit( | ||||||
|  |             InlayHintsConfig { binding_mode_hints: true, ..DISABLED_CONFIG }, | ||||||
|  |             r#" | ||||||
|  | fn main() { | ||||||
|  |     match &(0,) { | ||||||
|  |         (x,) | (x,) => (), | ||||||
|  |         ((x,) | (x,)) => (), | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | "#,
 | ||||||
|  |             expect![[r#" | ||||||
|  |                 fn main() { | ||||||
|  |                     match &(0,) { | ||||||
|  |                         &(&((ref x,) | (ref x,))) => (), | ||||||
|  |                         &((ref x,) | (ref x,)) => (), | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             "#]],
 | ||||||
|  |         ); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth