private static boolean isCaretAtTheLastLine(@NotNull Editor editor) {
    Document document = editor.getDocument();
    int caretOffset = editor.getCaretModel().getOffset();
    return document.getLineNumber(caretOffset) >= document.getLineCount() - 1;
  }
private static boolean isCaretAtTheLastLine(@NotNull Editor editor)