indentation using spaces should remove single space on backspace

Hi,

When using indentation using spaces, codemirror removes the complete bunch when pressing a backspace. For instance in the link shared - If I go 0 position of cursor and press tab, it will add 2 spaces. But when I hit backspace it removes the 2 spaces. It should treat space as single.

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIjsKaW1wb3J0IHsKICBrZXltYXAKfSBmcm9tICdAY29kZW1pcnJvci92aWV3JzsKaW1wb3J0IHtqYXZhc2NyaXB0fSBmcm9tICJAY29kZW1pcnJvci9sYW5nLWphdmFzY3JpcHQiCmltcG9ydCB7IGhpc3RvcnksIGRlZmF1bHRLZXltYXAsIGhpc3RvcnlLZXltYXAsIGluZGVudExlc3MsIGluZGVudE1vcmUgfSBmcm9tICdAY29kZW1pcnJvci9jb21tYW5kcyc7CmltcG9ydCB7CiAgaW5kZW50VW5pdCwKfSBmcm9tICdAY29kZW1pcnJvci9sYW5ndWFnZSc7CgoKbmV3IEVkaXRvclZpZXcoewogIGRvYzogImNvbnNvbGUubG9nKCdoZWxsbycpXG4iLAogIGV4dGVuc2lvbnM6IFtiYXNpY1NldHVwLCBqYXZhc2NyaXB0KCksCiAgICAgICAgICAgICAga2V5bWFwLm9mKFt7CiAgICBrZXk6ICdUYWInLAogICAgcHJldmVudERlZmF1bHQ6IHRydWUsCiAgICBydW46IGluZGVudE1vcmUsCiAgICBzaGlmdDogaW5kZW50TGVzcywKICB9XSksCiAgICAgICAgICAgICAgXSwKICBwYXJlbnQ6IGRvY3VtZW50LmJvZHkKfSkK

That’s not really your decision to make. The default deleteCharBackward command aligns to what many code editors do and deletes an entire unit of indentation. You can bind backspace to a custom command if you want to that behaves differently.

OK. Thank you for replying.

Hi @marijn,
I tried to create custom backspace based on the current deleteCharBackward implementation and found it complex. Specially when internal function deleteBy is not exported.
Is there a way to make the behaviour optional, or export deleteBy method to allow writing custom behaviour?

VS-Code allows it to be optional.

This patch adds a separate deleteCharBackwardStrict command.

That’s awesome!
Thank you so much. Can’t wait for the next CM release.

Tagged 6.4.0

That is superfast. Thank you so much!