Monospace formatting with backticks `` shifts following formatting ←left←

What’s The Bug?

Formatting text as monospace with backticks `` (Ctrl+L shortcut works fine) shifts all following words’ formatting (in the same paragraph) 2 symbols left (like a sliding window).

How To Reproduce It

  1. Go to the Anytype text editor window (create a note, page, etc.)
  2. Type text in one block (paragraph)
  3. Highlight and format some text (bold, italic, monospace, etc.) any way you wish (shortcut, mouse, etc.). We will call this formatted text “Substring A”.
  4. Highlight some other text that comes before the Substring A in the same paragraph. We will call this text “Substring B”.
  5. Press ` (backtick) once to format Substring B as monospace.
  6. The formatting of Substring A is now shifted 2 symbols left, so that 2 rightmost symbols of it are no longer formatted, and 2 symbols to the left of it are now formatted.

The Expected Behavior

Formatting of Substring A (refer to the “How to reproduce it” section) is expected not to be shifted at all when formatting Substring B using backticks ``.

Additional Context

I’m not completely sure that it is always exactly 2 symbols.

Device

Huawei MateBook B3-440

OS

Windows 10.0.19045

Anytype Version

v0.42.8

Network Mode

AnySync

Technical Information

OS version: win32 x64 10.0.19045
App version: 0.42.8
Build number: build on 2024-09-06 10:41:02 +0000 UTC at #c583602e975eaf2e525ef7f22e4700f8825a6420 (dirty)
Library version: v0.35.7
Anytype Identity: A9mMQe21vcZy9gNQfaXGgMnsACeRWb4em1c831mghzGi66wt
Analytics ID: 0dcb0667-55e9-4d48-9b14-5126a2087efe
Device ID: 12D3KooWLvqx4W57LDZAqpFKzNQBxCFVhYp7ra6FpTJa4PE1i3Vj

Very good first post here in our community, @yuritem ! :+1:

The issue seems to depend from the language of the PC.
On a German PC it behaves different, see my screen record.

For me, on my PC, the only tiny issue is that changing a substring in monofont adds an unwanted space char.
Nothing moves.

This report has been added to our issue tracker and received by the Development Team.

Hey Jack!

Thanks for the effort and the screen recording!

Apologies for the miscom: I meant “highlight” and wrote “select” :slight_smile: I edited the post now for future readers.

As for the whitespace in the end, I do experience this issue too, and this is not expected behavior either, thanks for mentioning that!

To add to the issue: same “shifing” behavior happens when writing "# " (with space) in the start of a paragraph to format it as a Heading 1.

Thanks for the correction.
But although your start post is made accurate and lists all the steps to reproduce the issue, I somehow don’t get it.

Points 4 and especially 5 are my problem.
If I select a substring and then press backtick, the selected text becomes overwritten (and that’s normal). I don’t understand why you seemingly have another result.

Could you please upload a screen record?

Sure, here it is :slight_smile:

I also noticed that the heading bug I mentioned in the reply only happens when the "# " is typed quickly enough.

Thanks.
But the only problem I see is the bug that the function adds a space char…

A mono font is wider than the normal font.
That’s why the text right from the cursor shifts a bit more to the right. That’s normal.

But in addition with the unwanted space char the function adds to the text, the shifting to the right becomes even one char bigger.

Result:
The only bug here is that the function adds a space char.

Look closely after 0:26 in my screen recording: when I format the word “invention” using backticks, all of the following formatting in the same paragraph slides left.

Before: “discovered the possibility” was formatted as monospace.
After: “e discovered the possibili” is formatted as monospace.

The recording goes on to show the same effect multiple times.

OK, now I’ve seen it.
And I already know a way to avoid that. But we really have a bug here.
One could even say there are two or three bugs.

  1. It’s a difference if you select a word by double clicking it (than it selects the space right from it also on my PC) or if you precise mark it with the mouse or keyboard, to avoid the unwanted selection of the space char.
    I can’t see your keystrokes or mouse clicks in the screen record, but I suppose you select a word by double clicking it?
    – Then I wonder why the space char right from the word becomes also selected on my PC, but not on your PC?

  2. It’s also a difference if you format the substring with backticks or if you use the button in the context menu.
    – On a German keyboard there is no separate backtick key, therefore I’m not able to directly do what you did in the same way. I need to do some keypresses more to get the same result. And then there is the difference to the use of the button in the context menu.

I suppose the team needs to have a deeper look what’s going on here!

As for the double clicks:

  • If I double click a word with mouse, it highlights the word and whatever whitespace that comes right after the word.
  • If I double tap a word with touchpad, it only highlights the word itself.

In the screen recording, I was highlighting words by double tapping using touchpad, so that the whitespace wasn’t getting highlighted.

This issue has been fixed by the Development Team and will be implemented in an upcoming release.