views:

159

answers:

1

I developped a package to extend Visual Studio. As part of it, I have a context menu that must process the whole text content of the active document (HTML editor).

I understand how to get the current selection : TextSelection txtSelection = (TextSelection)_bllManager.CurrentDocument.Selection;

But I dont't understand how to get the whole content of the code window in case nothing is selected.

Currently I use a work-around doing txtSelection.SelectAll() but it moves the cursor and I don't want that.

Any suggestion ?

Thanks.

A: 

It can be done using edit points:

var document = (TextDocument)_bllManager.CurrentDocument.Object("TextDocument");
var editPoint = document.CreateEditPoint(document.StartPoint);
var text = editPoint.GetText(document.EndPoint);
Elisha
Thanks a lot for your help !
Sylvain