Browse Source

Corrected reverting of editor options when C# binding's editor extension is detached.

pull/494/head
Andreas Weizel 11 years ago
parent
commit
5c084ed695
  1. 8
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs
  2. 6
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorAdapter.cs

8
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs

@ -65,6 +65,7 @@ namespace CSharpBinding
CodeManipulation codeManipulation; CodeManipulation codeManipulation;
CaretReferenceHighlightRenderer renderer; CaretReferenceHighlightRenderer renderer;
CodeEditorFormattingOptionsAdapter options; CodeEditorFormattingOptionsAdapter options;
TextEditorOptions originalEditorOptions;
public void Attach(ITextEditor editor) public void Attach(ITextEditor editor)
{ {
@ -92,6 +93,7 @@ namespace CSharpBinding
textViewServices.AddService(typeof(ITextEditorOptions), options); textViewServices.AddService(typeof(ITextEditorOptions), options);
// Set TextEditor's options to same object // Set TextEditor's options to same object
originalEditorOptions = textEditor.Options;
textEditor.Options = options; textEditor.Options = options;
} }
} }
@ -107,9 +109,9 @@ namespace CSharpBinding
if ((optionsService != null) && (optionsService == options)) if ((optionsService != null) && (optionsService == options))
textView.Services.RemoveService(typeof(ITextEditorOptions)); textView.Services.RemoveService(typeof(ITextEditorOptions));
// TODO Reset TextEditor options, too? // Reset TextEditor options, too?
// if ((textEditor.Options != null) && (textEditor.Options == options)) if ((textEditor.Options != null) && (textEditor.Options == options))
// textEditor.Options = SD.EditorControlService.GlobalOptions; textEditor.Options = originalEditorOptions;
} }
codeManipulation.Dispose(); codeManipulation.Dispose();

6
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorAdapter.cs

@ -80,8 +80,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
internal void DetachExtensions() internal void DetachExtensions()
{ {
if (extensions != null) { if (extensions != null) {
foreach (var extension in extensions) // Detach extensions in reverse order
extension.Detach(); for (int i = extensions.Count - 1; i >= 0; i--) {
extensions[i].Detach();
}
} }
// Switch to global options, if no specific options service is registered // Switch to global options, if no specific options service is registered

Loading…
Cancel
Save