Auto close brackets

This fixes the issue of autocompleting links in the middle of a block of
text.

The issue was that the autocomplete was working fine, but the link being
autocompleted was the entire rest of the text (hence no matches). By
adding close brackets automatically we limit the link to just that
intended.