Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

indentRange in multiline string literal #909

@s-cork

Description

@s-cork

Describe the issue

if using the indentRange function over a document with a multiline string (e.g. in python)
Then the indents within the string will get "zeroed".

I think the correct behaviour here should be to ignore indentation when it is within a multiline string literal.

x = """
Some content
    with an indented line
The above line will be unindented after calling indentRange
"""

Another example

x = (
    """Some content
with an indented line
The above line will be unindented after calling indentRange
"""
)

becomes

x = (
    """Some content
    with an indented line
    The above line will be unindented after calling indentRange
    """
)

Browser and platform

No response

Reproduction link

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions