diff --git a/RetailCoder.VBE/Inspections/QuickFixes/IgnoreOnceQuickFix.cs b/RetailCoder.VBE/Inspections/QuickFixes/IgnoreOnceQuickFix.cs index db83309267..a0de0d9fdc 100644 --- a/RetailCoder.VBE/Inspections/QuickFixes/IgnoreOnceQuickFix.cs +++ b/RetailCoder.VBE/Inspections/QuickFixes/IgnoreOnceQuickFix.cs @@ -10,12 +10,10 @@ namespace Rubberduck.Inspections.QuickFixes public class IgnoreOnceQuickFix : QuickFixBase { private readonly string _annotationText; - private readonly string _inspectionName; public IgnoreOnceQuickFix(ParserRuleContext context, QualifiedSelection selection, string inspectionName) : base(context, selection, InspectionsUI.IgnoreOnce) { - _inspectionName = inspectionName; _annotationText = "'" + Annotations.AnnotationMarker + Annotations.IgnoreInspection + ' ' + inspectionName; } @@ -39,7 +37,11 @@ public override void Fix() int commentStart; if (codeLine.HasComment(out commentStart) && codeLine.Substring(commentStart).StartsWith(ignoreAnnotation)) { - annotationText = codeLine + ", " + _inspectionName; + var indentation = codeLine.Length - codeLine.TrimStart().Length; + annotationText = string.Format("{0}{1},{2}", + new string(' ', indentation), + _annotationText, + codeLine.Substring(indentation + ignoreAnnotation.Length)); module.ReplaceLine(insertLine - 1, annotationText); } else diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs b/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs index 0c8dc92fa8..57d974d40f 100644 --- a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs +++ b/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs @@ -231,7 +231,7 @@ private string GetPropertyText() (_model.ImplementSetSetterType ? setterText : string.Empty)).TrimEnd() + Environment.NewLine; var propertyTextLines = propertyText.Split(new[] {Environment.NewLine}, StringSplitOptions.None); - return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines, "test")); + return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines, true)); } } } diff --git a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs b/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs index baa5081658..12e2e79e7a 100644 --- a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs +++ b/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs @@ -103,7 +103,11 @@ private void AddInterface() { interfaceComponent.Name = _model.InterfaceName; - interfaceModule.InsertLines(1, Tokens.Option + ' ' + Tokens.Explicit + Environment.NewLine); + var optionPresent = interfaceModule.CountOfLines > 1; + if (!optionPresent) + { + interfaceModule.InsertLines(1, Tokens.Option + ' ' + Tokens.Explicit + Environment.NewLine); + } interfaceModule.InsertLines(3, GetInterfaceModuleBody()); var module = _model.TargetDeclaration.QualifiedSelection.QualifiedName.Component.CodeModule; diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs b/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs index 2914ae23fe..d0e24e2bd2 100644 --- a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs +++ b/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs @@ -85,7 +85,7 @@ private void GeneratePreview(IExtractMethodModel extractMethodModel,IExtractMeth */ var extractedMethod = extractMethodProc.createProc(extractMethodModel); var code = extractedMethod.Split(new[]{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); - code = _indenter.Indent(code, "Preview").ToArray(); + code = _indenter.Indent(code).ToArray(); _view.Preview = string.Join(Environment.NewLine, code); } } diff --git a/RetailCoder.VBE/UI/Refactorings/EncapsulateFieldDialog.cs b/RetailCoder.VBE/UI/Refactorings/EncapsulateFieldDialog.cs index b300cd9683..55ef8e0b5e 100644 --- a/RetailCoder.VBE/UI/Refactorings/EncapsulateFieldDialog.cs +++ b/RetailCoder.VBE/UI/Refactorings/EncapsulateFieldDialog.cs @@ -164,7 +164,7 @@ private string GetPropertyText() (MustImplementSetSetterType ? setterText : string.Empty); var propertyTextLines = propertyText.Split(new[] { Environment.NewLine }, StringSplitOptions.None); - return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines, "test")); + return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines)); } private void ValidatePropertyName() diff --git a/RetailCoder.VBE/UI/RubberduckUI.Designer.cs b/RetailCoder.VBE/UI/RubberduckUI.Designer.cs index 35ab2388f6..3113ac186d 100644 --- a/RetailCoder.VBE/UI/RubberduckUI.Designer.cs +++ b/RetailCoder.VBE/UI/RubberduckUI.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.36373 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -2077,6 +2077,24 @@ public static string IndenterSettings_SpecialOptionsLabel { } } + /// + /// Looks up a localized string similar to Maintain vertical spacing. + /// + public static string IndenterSettings_VerticalSpacing { + get { + return ResourceManager.GetString("IndenterSettings_VerticalSpacing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Vertical Spacing. + /// + public static string IndenterSettings_VerticalSpacingLabel { + get { + return ResourceManager.GetString("IndenterSettings_VerticalSpacingLabel", resourceCulture); + } + } + /// /// Looks up a localized string similar to Inspect. /// diff --git a/RetailCoder.VBE/UI/RubberduckUI.resx b/RetailCoder.VBE/UI/RubberduckUI.resx index ebeff93fd3..c4f3f5cb7d 100644 --- a/RetailCoder.VBE/UI/RubberduckUI.resx +++ b/RetailCoder.VBE/UI/RubberduckUI.resx @@ -1902,4 +1902,10 @@ End Sub Smart Indenter settings were found in your registry. Would you like to import them to Rubberduck? + + Maintain vertical spacing + + + Vertical Spacing + \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Settings/IndenterSettings.xaml b/RetailCoder.VBE/UI/Settings/IndenterSettings.xaml index f151557523..d0f4acaf74 100644 --- a/RetailCoder.VBE/UI/Settings/IndenterSettings.xaml +++ b/RetailCoder.VBE/UI/Settings/IndenterSettings.xaml @@ -194,6 +194,23 @@ NumValue="{Binding IndentSpaces, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinNumber="0"/> +