Improve closebrackets.js addon

Fixes #1335

- Do not insert closing bracket if a spacechar or closing bracket
  follows cursor
- Do not handle backspace if selection is not empty
- Do not overwrite anything if selection is not empty
- If selection is not empty and open bracket is inserted - surround
  selection with brackets.