vsx - Visual Studio own collapsed outline will be expanded -
my problem visual studio (vs2013) opens created , collapsed outline. goal want achieve automatically close first comment in source code file in window activate event. background have big fileheadercomments (visual source safe checkin history) in our source files.
i wrote extension creates outline block on first comment in file collapse it. works fine files open.
but if file opened newly (fileopen/documentopen) outline expanded after few seconds. think @ time, when automatic outlining of visual studio finished?!
also if execute command edit.stopautomaticoutling before outlining. after 2 3 seconds outline expanded.
here code outlining:
// outlining stoppen
try
{
_dte.executecommand("edit.stopoutlining");
}
catch (exception)
{
}
// oberflächenänderungen abschalten
_dte.suppressui = true;
textselection ts = _dte.activedocument.selection textselection;
if (ts != null)
{
// alte sektion merken
textpoint oldanchor = ts.anchorpoint.createeditpoint();
textpoint oldactive = ts.activepoint.createeditpoint();
// kommentare und leerzeilen zusammenfassen
editpoint edit_point = ts.activepoint.createeditpoint();
edit_point.startofdocument();
bool bwascomment = true;
bool binblock = false;
string line = "";
while (bwascomment && !edit_point.atendofdocument)
{
line = edit_point.getlines(edit_point.line, edit_point.line + 1);
if (!binblock)
{
if (line.trim().startswith("/"))
{
binblock = true;
bwascomment = true;
}
else if (line.trim().startswith("//"))
{
bwascomment = true;
}
else if (line.trim() == "")
{
bwascomment = true;
}
else
{
// anderes
bwascomment = false;
}
}
else
{
if (line.trim().endswith("/"))
{
binblock = false;
}
bwascomment = true;
}
if (!bwascomment)
{
if (!edit_point.atstartofdocument)
{
edit_point.lineup();
}
}
else
{
// weiter
edit_point.linedown();
}
}
// letze leerzeilen wieder hoch
if (!bwascomment)
{
line = edit_point.getlines(edit_point.line, edit_point.line + 1);
while (!edit_point.atstartofdocument && line.trim() == "")
{
edit_point.lineup();
line = edit_point.getlines(edit_point.line, edit_point.line + 1);
}
edit_point.endofline();
}
// outline erstellen und zuklappen
ts.movetoabsoluteoffset(1);
ts.swapanchor();
ts.movetoabsoluteoffset(edit_point.absolutecharoffset, true);
ts.outlinesection();
//ts.collapse(); // outlinesection() klappt schon zu
// cursor wieder umsetzen
if (oldanchor.absolutecharoffset < edit_point.absolutecharoffset)
{
// alte position war im kommentar -> direkt hinter neue region
ts.movetoabsoluteoffset(edit_point.absolutecharoffset); // set active point
ts.swapanchor(); //set anchor active point
ts.movetoabsoluteoffset(edit_point.absolutecharoffset, true);
}
else
{
// alte position
ts.movetoabsoluteoffset(oldanchor.absolutecharoffset); // set active point
ts.swapanchor(); //set anchor active point
ts.movetoabsoluteoffset(oldactive.absolutecharoffset, true);
}
_dte.suppressui = false;
}
Comments
Post a Comment