I tested the patch. The scenarios when press down-arrow key after select-all seem to be fixed, but cases when press up-arrow key have now a different, unexpected behavior: the cursor is placed at the beginning of the previous block node found before the last one.
Steps for reproducing:
before select-all, cursor is placed at the end of the last line of the document.
select all
press up-arrow
result: the cursor is placed in front of the previous line, see attached pictures.
Notes: it doesn’t matter where you place the cursor before the select-all is made.