Highlight color not show if there is space preceding highlited text

(Adapted from a bug report that was not accepted)

Use case or problem

Obsidian should highlight (show the text in highlight background color) even if the user selected text contains preceding or trailing space. Without this improvement, when I select text quickly, there is almost always a space preceding the text I intend to highlight, and as a result, Obsidian doesn’t display the text as highlighted, then I have to do it again, very slowly.

Steps to reproduce

  1. Open any note, and type Markdown Hello World
  2. Select Hello World, including the space preceding it
  3. Press the keyboard shortcut for Highlight (adding == to wrap the selected text)

Expected result

Either of the following:
A. The text will become Markdown== Hello World==. When previewed, ⎵Hello World is highlighted in color.
OR:
B. The text will become Markdown ==Hello World== (the selection is fixed so that there is no space preceding or concluding the selected text). When previewed, Hello World is highlighted in color.

Actual result

The text will become Markdown== Hello World==. When previewed, Hello World is not highlighted in color. There is no highlight anywhere in the note.

Environment

  • Operating system: Windows 10

  • Obsidian version: 0.12.15