public static Position ToLinePosition(this IEditorBufferSnapshot snapshot, int position) { var line = snapshot.GetLineFromPosition(position); return(new Position { Line = line.LineNumber, Character = position - line.Start }); }
public static bool IsPositionInNamespace(this IEditorBufferSnapshot snapshot, int position) { if (position > 0) { var line = snapshot.GetLineFromPosition(position); if (line.Length > 2 && position - line.Start > 2) { return(snapshot[position - 1] == ':'); } } return(false); }
private static ITextRange GetRoxygenBlockPosition(IEditorBufferSnapshot snapshot, int definitionStart) { var line = snapshot.GetLineFromPosition(definitionStart); for (var i = line.LineNumber - 1; i >= 0; i--) { var currentLine = snapshot.GetLineFromLineNumber(i); var lineText = currentLine.GetText().TrimStart(); if (lineText.Length > 0) { if (lineText.EqualsOrdinal("##")) { return(currentLine); } if (lineText.EqualsOrdinal("#'")) { return(null); } break; } } return(new TextRange(line.Start, 0)); }