public static SearchResult CreateSearchResult(this ITextDocument document, Location location) { int startOffset = document.PositionToOffset(location.Range.Start); int endOffset = document.PositionToOffset(location.Range.End); var provider = new FileProvider(location.Uri.ToFilePath(), null, startOffset, endOffset); return(new SearchResult(provider, startOffset, endOffset - startOffset)); }
public static TextSegment GetTextSegment(this ITextDocument editor, Range range) { if (range != null) { int startOffset = editor.PositionToOffset(range.Start); int endOffset = editor.PositionToOffset(range.End); return(new TextSegment(startOffset, endOffset - startOffset)); } return(TextSegment.Invalid); }