Пример #1
0
        public int GetSelectedText(out string pbstrText)
        {
            TextSpan[] span = new TextSpan[1];
            ErrorHandler.ThrowOnFailure(intellisenseHost.GetContextSelection(span));
            TextSpan[] convertedSpan = new TextSpan[1];
            ErrorHandler.ThrowOnFailure(bufferCoordinator.MapPrimaryToSecondarySpan(span[0], convertedSpan));
            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));
            return(buffer.GetLineText(convertedSpan[0].iStartLine, convertedSpan[0].iStartIndex, convertedSpan[0].iEndLine, convertedSpan[0].iEndIndex, out pbstrText));
        }