From 5f58f9ccb814a2367120d3e2090dfb177378766a Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 4 Sep 2014 19:33:31 +0200 Subject: [PATCH] fix #550: Code actions insert tabs when they should use spaces --- .../Project/Src/ExtensionMethods.cs | 17 +++++++++++------ .../Src/Refactoring/SDRefactoringContext.cs | 9 +++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs index 723ef18697..3b01520eb9 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs @@ -37,14 +37,19 @@ namespace CSharpBinding public static class ExtensionMethods { public static TextEditorOptions ToEditorOptions(this ITextEditor editor) + { + return ToEditorOptions(editor.Options); + } + + public static TextEditorOptions ToEditorOptions(this ITextEditorOptions options) { return new TextEditorOptions { - TabsToSpaces = editor.Options.ConvertTabsToSpaces, - TabSize = editor.Options.IndentationSize, - IndentSize = editor.Options.IndentationSize, - ContinuationIndent = editor.Options.IndentationSize, - LabelIndent = -editor.Options.IndentationSize, - WrapLineLength = editor.Options.VerticalRulerColumn, + TabsToSpaces = options.ConvertTabsToSpaces, + TabSize = options.IndentationSize, + IndentSize = options.IndentationSize, + ContinuationIndent = options.IndentationSize, + LabelIndent = -options.IndentationSize, + WrapLineLength = options.VerticalRulerColumn }; } diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs index 1fa3af1f23..1abfe05bbf 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs @@ -44,6 +44,7 @@ namespace CSharpBinding.Refactoring readonly ITextEditor editor; readonly ITextSource textSource; readonly TextLocation location; + readonly TextEditorOptions editorOptions; IDocument document; int selectionStart, selectionLength; @@ -86,6 +87,7 @@ namespace CSharpBinding.Refactoring this.selectionStart = selectionStart; this.selectionLength = selectionLength; this.location = location; + this.editorOptions = SD.EditorControlService.GlobalOptions.ToEditorOptions(); InitializeServices(); } @@ -99,6 +101,7 @@ namespace CSharpBinding.Refactoring this.selectionStart = editor.SelectionStart; this.selectionLength = editor.SelectionLength; this.location = location; + this.editorOptions = editor.ToEditorOptions(); InitializeServices(); } @@ -131,6 +134,12 @@ namespace CSharpBinding.Refactoring } } + public override TextEditorOptions TextEditorOptions { + get { + return editorOptions; + } + } + public IDocument Document { get { IDocument result = LazyInit.VolatileRead(ref document);