I lose indentation, or gain extra newlines

Using this forum just now, I discovered a strange thing. First of all, here’s my environment: I’m running Visual Studio on Windows in a virtual machine under Parallels under Mac OS. I can run my browser, DuckDuckGo, on Windows or Mac.

Now, the weirdness: if I copy code from Visual Studio (or Notepad) and paste it into a new topic on this forum on the Mac, indentation is preserved but every newline turns into two new lines, so everything is doublespaced. If I instead paste it into a new topic on this forum under Windows, I get single spacing but indentation is destroyed: all leading spaces or tabs are lost. (In the original, they are in fact spaces.)

Are these issues understood? Is there a way to do better?