def at_the_end(b: Buffer) -> bool:
            """we consider the cursor at the end when there is no text after
            the cursor, or only whitespace."""
            text = b.document.text_after_cursor
            return text == "" or (text.isspace() and "\n" not in text)
we consider the cursor at the end when there is no text after
            the cursor, or only whitespace.
src/ptpython/key_bindings.py