private static IEditorLine FindFirstNonEmptyLine(IEditorBufferSnapshot snapshot, int lineNumber) { for (int i = lineNumber; i < snapshot.LineCount; i++) { var line = snapshot.GetLineFromLineNumber(i); if (!string.IsNullOrWhiteSpace(line.GetText())) { return(line); } } return(null); }
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)); }
public static int ToStreamPosition(this IEditorBufferSnapshot snapshot, int lineNumber, int charNumber) { var line = snapshot.GetLineFromLineNumber(lineNumber); return(line?.Start + charNumber ?? 0); }