I am opening a new editor view to display formatted code. The contents are
not read from a file. I create the view by calling
_DTE.ItemOperations.NewFile. I then insert the text into the view in one of
two ways: creating a TextSelection from the ActiveDocument, or updating the
IVsTextLines of the active view. In either case, the whole view has the
yellow line down the left side showing that it is all editted. This
essentially is true since I've added text to a new empty file.
I realize that I could first dump the contents I want to display to a file
and then just open the file, but I'd rather not write to disk and then have
to erase it. Is there a better way to display code is an editor view (just
like opening a real file) or, better yet, is there a way to block/remove the
yellow line once I display the text/code as I do now?
Thank you,
-DOB-
"Ed Dore [MSFT]" - 05 Aug 2005 18:05 GMT
Hi Dave,
There are actually a few ways to deal with this, provided you are using
Whidbey Beta 2 (or later). There is a new interface called IVsTextBufferEx
defined in TEXTMGR2.IDL which you can use to suppress the tracking.
Specifically, IVsTextBufferEx::SetTrackChangesSuppression.
Alternatively, you should initialize your VsTextBuffer object by calling
IVsTextBuffer::InitializeContent(). The change tracking doesn't kick in
until after this is called. If you add text manually (or programatically)
by some other means, those yellow and green margins will appear. But if you
set the initial text in that InitializeContent call, then the initial text
will not be marked as changed text.
If you want to loose the feature altogether, you can also use
IVsCodeWindowEx::Initialize() and use the VIF_SUPPRESSTRACKCHANGES flag.
This is also defined in the TEXTMGR2.IDL file.
The interfaces and flags also appear to be defined in the
Microsoft.VisualStudio.TextManager.Interop.8.0. assembly as well. So you
should be able to do this from managed packages as well.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.