forked from NoahRic/FixMixedTabs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MarginFactory.cs
47 lines (39 loc) · 1.59 KB
/
MarginFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.ComponentModel.Composition;
using System.Diagnostics;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.Utilities;
namespace FixMixedTabs
{
#region InformationBar Factory
[Export(typeof(IWpfTextViewMarginProvider))]
[Name(InformationBarMargin.MarginName)]
[MarginContainer(PredefinedMarginNames.Top)]
[ContentType("any")]
[TextViewRole(PredefinedTextViewRoles.Editable)]
internal sealed class MarginFactory : IWpfTextViewMarginProvider
{
[Import]
ITextDocumentFactoryService TextDocumentFactoryService = null;
[Import]
IEditorOperationsFactoryService OperationsFactory = null;
[Import]
ITextUndoHistoryRegistry UndoHistoryRegistry = null;
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
{
IWpfTextView view = textViewHost.TextView;
ITextDocument document;
if (!TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document))
return null;
ITextUndoHistory history;
if (!UndoHistoryRegistry.TryGetHistory(view.TextBuffer, out history))
{
Debug.Fail("Unexpected: couldn't get an undo history for the given text buffer");
return null;
}
return new InformationBarMargin(view, document, OperationsFactory.GetEditorOperations(view), history);
}
}
#endregion
}