Issue/comment auto edit improvements

My second try to fix auto closing multi line comments.

For more information on the changes see the commit messages.

Should be backported to 3.0