@@ -2711,8 +2711,16 @@ impl<'ast> ast::visit::Visit<'ast> for ExtractVariable<'ast> {
2711
2711
if self . position != Some ( ExtractVariablePosition :: TopLevelStatement )
2712
2712
&& within ( self . params . range , expr_range)
2713
2713
{
2714
- self . selected_expression = Some ( expr_location) ;
2715
- self . statement_before_selected_expression = self . latest_statement ;
2714
+ match expr {
2715
+ // We don't extract variables, they're already good.
2716
+ // And we don't extract module selects by themselves but always
2717
+ // want to consider those as part of a function call.
2718
+ TypedExpr :: Var { .. } | TypedExpr :: ModuleSelect { .. } => ( ) ,
2719
+ _ => {
2720
+ self . selected_expression = Some ( expr_location) ;
2721
+ self . statement_before_selected_expression = self . latest_statement ;
2722
+ }
2723
+ }
2716
2724
}
2717
2725
2718
2726
let previous_position = self . position ;
@@ -2744,20 +2752,6 @@ impl<'ast> ast::visit::Visit<'ast> for ExtractVariable<'ast> {
2744
2752
self . position = previous_position;
2745
2753
}
2746
2754
2747
- // We don't want to offer the action if the cursor is over a variable
2748
- // already!
2749
- fn visit_typed_expr_var (
2750
- & mut self ,
2751
- location : & ' ast SrcSpan ,
2752
- _constructor : & ' ast type_:: ValueConstructor ,
2753
- _name : & ' ast EcoString ,
2754
- ) {
2755
- let var_range = self . edits . src_span_to_lsp_range ( * location) ;
2756
- if within ( self . params . range , var_range) {
2757
- self . selected_expression = None ;
2758
- }
2759
- }
2760
-
2761
2755
// We don't want to offer the action if the cursor is over some invalid
2762
2756
// piece of code.
2763
2757
fn visit_typed_expr_invalid ( & mut self , location : & ' ast SrcSpan , _type_ : & ' ast Arc < Type > ) {
0 commit comments