diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs index 36958f4f4d..7ef4cd3ccc 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.PrettyPrinter; @@ -430,6 +431,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring } } IOutputAstVisitor outputVisitor = (language==NR.SupportedLanguage.CSharp) ? new CSharpOutputVisitor() : (IOutputAstVisitor)new VBNetOutputVisitor(); + var match = Regex.Match(codeForNewType, @"^([\s]+)", RegexOptions.Multiline); + if (match != null && !string.IsNullOrEmpty(match.Groups[0].Value)) { + outputVisitor.Options.IndentationChar = match.Groups[0].Value[0]; + } + using (SpecialNodesInserter.Install(comments, outputVisitor)) { parser.CompilationUnit.AcceptVisitor(outputVisitor, null); }