public void FindNextWordStart7() { Create("foo bar jazz"); var next = TssUtil.FindNextWordStart(_snapshot.GetPoint(0), 2, WordKind.NormalWord); Assert.AreEqual('j', next.GetChar()); }
/// <summary> /// Get a <see cref="Span"/> representing the specified range within the <paramref name="snapshot"/>. /// </summary> /// <param name="snapshot"> /// The <see cref="ITextSnapshot"/>. /// </param> /// <param name="range"> /// The target LSP <see cref="Range"/>. /// </param> /// <returns> /// The <see cref="Span"/>. /// </returns> public static Span GetSpan(this ITextSnapshot snapshot, Range range) { if (snapshot == null) { throw new ArgumentNullException(nameof(snapshot)); } if (range == null) { throw new ArgumentNullException(nameof(range)); } SnapshotPoint start = snapshot.GetPoint(range.Start); SnapshotPoint end = snapshot.GetPoint(range.End); return(new Span( start: start.Position, length: end.Position - start.Position )); }
/// <summary> /// Get a <see cref="SnapshotPoint"/> representing the specified position in the <paramref name="snapshot"/>. /// </summary> /// <param name="snapshot"> /// The <see cref="ITextSnapshot"/>. /// </param> /// <param name="position"> /// The target LSP <see cref="Position"/>. /// </param> /// <returns> /// The <see cref="SnapshotPoint"/>. /// </returns> public static SnapshotPoint GetPoint(this ITextSnapshot snapshot, Position position) { if (snapshot == null) { throw new ArgumentNullException(nameof(snapshot)); } if (position == null) { throw new ArgumentNullException(nameof(position)); } return(snapshot.GetPoint(position.Line, position.Character)); }