Add-in trouble with indent when inserting two lines of code
i using studio add-in add 2 lines of code in source document. indent not respected on second line. how can indent properly.
textselection objsel = (envdte.textselection)(_applicationobject.activedocument.selection);string
firstline = "//modification de : " + system.environment.username + " version ??? - " + datetime.now.tostring(); string secondline = "//appel# "; if (system.io.file.exists(@"p:\maximum.net\maximum\activecall.txt")){
//get file textsystem.io.
streamreader re = system.io.file.opentext(@"p:\maximum.net\maximum\activecall.txt");secondline = secondline + re.readtoend();
secondline = secondline.trim();
}
string
finaloutput = firstline + " \n" + secondline;objsel.insert(finaloutput, system.
convert.toint32(vsinsertflags.vsinsertflagsinsertatend));
finally got wokring using collapse method;
final code looks this:
textselection objsel = (envdte.textselection)(_applicationobject.activedocument.selection);
string
firstline = "//modification de : " + system.environment.username + " version ??? - " + datetime.now.tostring(); string secondline = "//appel# "; if (system.io.file.exists(@"p:\maximum.net\maximum\activecall.txt")){
//get file textsystem.io.
streamreader re = system.io.file.opentext(@"p:\maximum.net\maximum\activecall.txt");secondline = secondline + re.readtoend();
secondline = secondline.trim();
}
objsel.text = firstline +
"\n";objsel.collapse();
objsel.text = secondline;
objsel.collapse();
Archived Forums V > Visual C# IDE
Comments
Post a Comment