[ContentType("Code")]
[Export(typeof(IWpfTextViewCreationListener))]
[TextViewRole(PredefinedTextViewRoles.Editable)]
internal sealed class TextViewCreationListener : IWpfTextViewCreationListener
{
public void TextViewCreated(IWpfTextView textView)
{
ClassTemplateWriter.initializeFromParent(textView);
}
}
public static void initializeMembers(string className)
{
ClassTemplateWriterMembers.className = className;
ClassTemplateWriterMembers.resetSnapshotLength();
ClassTemplateWriterMembers.edit = ClassTemplateWriterMembers.view.TextBuffer.CreateEdit();
}
I'm trying to make a Visual Studio Extension adding code in the active document's editor(or buffer). So far everything was good except,
I select file1 and run the command, select file2 and run the command there. Now if I select the previous file and run the command the code is added in file1 not file2.
The problem is after the view for file1 and file2 is created using the TextViewCreate, If I want to reset 'edit' with the active document's view, (using the function above 'initializeMembers') ClassTemplateWriter's view member isn't the active document's view but the lastly created view.
How can I reset the member view with the active document's view?
(By active document I mean the document I'm currently running the command on. which is dte.ActiveDocument)