From 187219a6143a9757957938de523a3490965cab06 Mon Sep 17 00:00:00 2001 From: sven-n Date: Mon, 4 Nov 2013 20:08:07 +0100 Subject: [PATCH] Fix indentation for 'Move class to File' function 'Move class to File' function did always use tab as indentation character. As space user you always had to convert the tabs to spaces by hand afterwards. This fix tries to find and set the right indentation character. If no indentation character is found, it falls back to tab. --- .../Src/Refactoring/NRefactoryRefactoringProvider.cs | 6 ++++++ 1 file changed, 6 insertions(+) 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); }