/// <summary>
/// Maps given point from view buffer to R editor buffer
/// </summary>
public static SnapshotPoint?MapPointFromView(ITextView textView, SnapshotPoint point)
{
ITextBuffer rBuffer;
SnapshotPoint?documentPoint = null;
IREditorDocument document = REditorDocument.FindInProjectedBuffers(textView.TextBuffer);
if (document != null)
{
rBuffer = document.TextBuffer;
}
else
{
// Last resort, typically in unit tests when document is not available
rBuffer = REditorDocument.FindRBuffer(textView.TextBuffer);
}
if (rBuffer != null)
{
if (textView.BufferGraph != null)
{
documentPoint = textView.MapDownToBuffer(point, rBuffer);
}
else
{
documentPoint = point;
}
}
return(documentPoint);
}