def get_line_end(code, offset):
    """
    NOTE: Slight rework of method in rope. Maybe change it upstream so it can be used here?
    """
    try:
        return code.index('\n', offset)
    except ValueError:
        return len(code)
