Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Text#fromAttributed): Fix StyleRun assuming that the startIndex and length always exist #862

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonz94
Copy link
Contributor

@jonz94 jonz94 commented Jan 5, 2025

Fixes #850
Fixes #854

In AttributedText, styleRuns may not always include the startIndex or length properties

  • If startIndex is missing, we assume the style applies from the beginning of the text
  • If length is missing, we assume the style applies to the entire text

Example RawNode data:

{
  "contentMetadataViewModel": {
    "metadataRows": [
      {
        "metadataParts": [
          {
            "text": {
              "content": "@pbsspacetime",
              "styleRuns": [
                {
                  "weightLabel": "FONT_WEIGHT_MEDIUM",
                  "styleRunExtensions": {
                    "styleRunColorMapExtension": {
                      "colorMap": [
                        {
                          "key": "USER_INTERFACE_THEME_LIGHT",
                          "value": 4279440147
                        },
                        {
                          "key": "USER_INTERFACE_THEME_DARK",
                          "value": 4294967295
                        }
                      ]
                    }
                  }
                }
              ]
            },
            "enableTruncation": true
          }
        ]
      }
    ],
    "delimiter": ""
  }
}

…x` and `length` always exist

In AttributedText, styleRuns may not always include the `startIndex` or `length` properties
- If `startIndex` is missing, we assume the style applies from the beginning of the text
- If `length` is missing, we assume the style applies to the entire text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to find matching run for command run. v12.2.0 Unable to find matching run for style run
1 participant