Click inside a mark decoration doesn't position cursor

I’m developing a Slack-like text editor with support for inline code blocks – a piece of text between a pair or backticks. I’m using Match Decorator to detect all occupancies of enclosed text and apply Mark Decoration (not Decoration.replace) to it.

It works well, except I can’t click inside the marked piece of text to position the cursor. See the demo and try to click inside the CODE span – you can’t position the cursor inside of it. Though it’s possible to do if you move the cursor with arrow keys.

How to prevent CM from skipping the matched part of text when clicking?

After sifting through a lot of irrelevant code in that example script, it looks like you’re just explicitly using EditorView.atomicRanges, which enforces precisely the behavior you are complaining about here.

Thank you! I’m sorry for rubbish in the code, I removed all irrelevant pieces in the demo. I was able to “fix” this behaviour by using minimalSetup extension at line 110 and by replacing optionalAccess to call at line 31. I have no I idea what I just did and why it works. Can you please explain what this argument is about?