I have had many troubles getting code to display correctly, until I finally figured it out after trying to edit a post so incorrectly that a special message popped up telling me that I needed 4 spaces and perhaps I should press ctrl-k. Voila! I repasted my code, highlighted it, pressed ctrl-k and was done. For something that is so simple it should really be mentioned somewhere when you click "Code Sample" in the edit tool bar.
So, I propose a combination of two things:
When you click "Code Sample", it should say "to create code block highlight the desired code and click either the braces on the top, or hit ctrl-k".
In the help text on the right it should say "all lines of code must be indented 4 lines" (rather than the current "indent code by 4 spaces"), to make it clear that the operation shouldn't only be done to the first and last lines. This is necessary as other similar operations such as
[code]
on other sites only need to be put at the beginning yet apply to everything until[/code]
.