It is nice that Discourse allows toggling of text attributes. Many forums I use simply insert the codes around the selected text and do not toggle the attributes if I apply the same attribute to the same selection.
When you bold text and then unbold it, the editor appears to assume only the bolded text is selected. If you select the bold text and the markup the text will be unbolded but the selection is shifted right by the two markup characters that no longer exist so the following text is selected by the four markup characters that no longer exist:
Even worse if you select an entire line when only the last word is bolded then you lose text:
Test bold
No bold text
Lose the first two characters of the line:
st **bold
No bold text
If the bold text is not at the end of the line then I lose no text although the markup could be improved:
Test bold text
No bold text
The same occurs with italic but I only lose one character because the markup is only one character:
est _italic
No italic text