I'm creating a Visual Studio 2013 plugin (ok, extension package actually) that seeks to paste certain strings* into a currently open .vb or .cs file, but when I get to the point of doing the actual pasting of text the editor instance freezes up for a while. If there are reletively few lines, VS will come back after a few seconds, but for 20+ lines the editor just never comes back.
This is the gist of what my code looks like:
String myText = "foo";
DTE dte = this.GetService(typeof(DTE)) as DTE;
EnvDTE.TextSelection selection = (dte.ActiveDocument.Selection as EnvDTE.TextSelection);
selection.Text = "";
//Here myText ends up having some content written into it
selection.Text = myText; //VS hangs after this point
Any clues as to what I can do to fix (or at least debug) this? I've tried VS's Profiler but all I get is that 98% of the time is wasted on "msenv.dll" and I can't see what's going on inside..
*(takes SQL from the clipboard and breaks it into lines wrapped in AppendLine calls to a StringBuilder)