Repeating Toggle Comment on the same word adds more and more space

Steps to reproduce

  • Write a few words. For our testing I’m using the Sandbox Vault > Start here > “Hi, welcome to Obsidian!” sentence
  • Put your cursor on some word, e.g. welcome
  • Toggle Comment (I recommend using shortcut Ctrl+/ to chain faster)
  • Repeat Toggle Comment many times

Did you follow the troubleshooting guide? [Y/N]

Y

Expected result

After an odd number of Toggle Comment:

Hi, welcome to Obsidian!

After an even number of Toggle Comment:

Hi, %% welcome %% to Obsidian!

Actual result

From initial state to 6th Toggle Comment:

Hi, welcome to Obsidian!
Hi, %% welcome %% to Obsidian!
Hi,  welcome  to Obsidian!
Hi,  %% welcome %%  to Obsidian!
Hi,   welcome   to Obsidian!
Hi,   %% welcome %%   to Obsidian!
Hi,    welcome    to Obsidian!

Note: the word “welcome” is highlighted every time, and not the spaces around. I think this particular behavior makes space. Toggle comment should probably just detect the space betwee word and %% and delete it (if there is also a space beyond the %%).

Environment

SYSTEM INFO:
Obsidian version: 1.12.7
Installer version: 1.8.10
Operating system: Windows 11 Pro 10.0.26100
Login status: not logged in
Language: en
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 3
Plugins enabled: 3
1: Excalidraw v2.25.2
2: Paste Reformatter v1.4.2
3: Better Comment Toggle v1.0.3
RECOMMENDATIONS:
Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.


Additional information

I prepared a video but apparently I have to upload it elsewhere, I’m not sure it’s worth the hassle considering it’s easy to repro, but I can share one from Dropbox or Google Drive on demand.

A post was merged into an existing topic: (Un)Toggle comment does not remove spaces