@@ -379,33 +379,38 @@ private void UpdateMenuItems()
379
379
refactorContextMenu . MoveMenuItem . Enabled = false ;
380
380
this . surroundContextMenu . Enabled = false ;
381
381
this . refactorMainMenu . SurroundMenu . Enabled = false ;
382
- this . refactorContextMenu . ExtractMethodMenuItem . Enabled = false ;
383
- this . refactorContextMenu . ExtractLocalVariableMenuItem . Enabled = false ;
384
382
this . refactorMainMenu . ExtractMethodMenuItem . Enabled = false ;
383
+ this . refactorContextMenu . ExtractMethodMenuItem . Enabled = false ;
385
384
this . refactorMainMenu . ExtractLocalVariableMenuItem . Enabled = false ;
385
+ this . refactorContextMenu . ExtractLocalVariableMenuItem . Enabled = false ;
386
386
ITabbedDocument document = PluginBase . MainForm . CurrentDocument ;
387
387
if ( document != null && document . IsEditable && langIsValid )
388
388
{
389
389
bool isValidFile = IsValidFile ( document . FileName ) ;
390
390
refactorMainMenu . MoveMenuItem . Enabled = isValidFile ;
391
391
refactorContextMenu . MoveMenuItem . Enabled = isValidFile ;
392
- if ( document . SciControl . SelTextSize > 1 )
392
+ var sci = document . SciControl ;
393
+ if ( sci . SelTextSize > 0 )
393
394
{
394
- Int32 selEnd = document . SciControl . SelectionEnd ;
395
- Int32 selStart = document . SciControl . SelectionStart ;
396
- if ( ! document . SciControl . PositionIsOnComment ( selEnd ) || ! document . SciControl . PositionIsOnComment ( selStart ) )
395
+ if ( ! sci . PositionIsOnComment ( sci . SelectionStart ) || ! sci . PositionIsOnComment ( sci . SelectionEnd ) )
397
396
{
398
397
this . surroundContextMenu . Enabled = true ;
399
398
this . refactorMainMenu . SurroundMenu . Enabled = true ;
400
- this . refactorContextMenu . ExtractMethodMenuItem . Enabled = true ;
401
399
this . refactorMainMenu . ExtractMethodMenuItem . Enabled = true ;
402
- this . refactorContextMenu . ExtractLocalVariableMenuItem . Enabled = true ;
400
+ this . refactorContextMenu . ExtractMethodMenuItem . Enabled = true ;
401
+ }
402
+ var declAtSelStart = context . GetDeclarationAtLine ( sci . LineFromPosition ( sci . SelectionStart ) ) ;
403
+ var declAtSelEnd = context . GetDeclarationAtLine ( sci . LineFromPosition ( sci . SelectionEnd ) ) ;
404
+ if ( declAtSelStart != null && declAtSelStart . Member != null && ( declAtSelStart . Member . Flags & FlagType . Function ) > 0
405
+ && declAtSelEnd != null && declAtSelStart . Member . Equals ( declAtSelEnd . Member ) )
406
+ {
403
407
this . refactorMainMenu . ExtractLocalVariableMenuItem . Enabled = true ;
408
+ this . refactorContextMenu . ExtractLocalVariableMenuItem . Enabled = true ;
404
409
}
405
410
}
406
411
}
407
- this . refactorContextMenu . CodeGeneratorMenuItem . Enabled = isValid ;
408
412
this . refactorMainMenu . CodeGeneratorMenuItem . Enabled = isValid ;
413
+ this . refactorContextMenu . CodeGeneratorMenuItem . Enabled = isValid ;
409
414
}
410
415
catch { }
411
416
}
0 commit comments