Usually, you should avoid edits to code, especially in questions. I'd recommend reading "When should I make edits to code?" for more information about why.
- improve spelling & grammar
This looks good, and we generally appreciate spelling and grammar edits. You'll find that, for the most part, edits containing only spelling and grammar edits will be approved. The one exception to this is if there are only a few, or it's clear that there are other edits that should have been made.
One of the glaring edits I see that was missing was the formatting of the code blocks, which are clearly indented way too far. Most likely it was copied and pasted from an editor and the formatting was not fixed, but formatting is something you can easily fix.
- removed totally unimportant code parts for brevity
This can sometimes be OK in answers if it's clear that the code can be removed, and your suggested edit tries to explain why they were removed. But questions are special, because editing code in questions has a tendency to invalidate answers. It's common for question edits to change code to be rejected with the reason you were given because we feel that it's better to leave a comment and let the question asker make the edit.
I personally wouldn't have made this edit, so I can't think of a comment you could have used.
- merged three blocks into one long block
I have mixed feelings about this. In some cases, combining code blocks makes it more difficult to follow the questions. But quite often, it makes it more difficult to follow because you typically don't see it happen and you don't know right away why there are three similar blocks of code next to each other. I personally would skip the edit review if it was just this, but others would very likely reject it for having no improvement.