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

More consistent return value for annotations #53281

Merged

Commits on Feb 11, 2024

  1. More consistent return value for annotations

    There are two different kinds of return value that annotations may
    currently produce.
    1. A vector of annotations (Pair{Symbol, Any})
    2. A vector of region-annotation tuples (Tuple{UnitRange{Int},
       Pair{Symbol, Any}})
    
    Currently, there is an excess of argument-return-type combinations:
    1. (string) -> vector of region-annotation tuples
    2. (substring, region) -> vector of annotation values
    3. (string, region/index) -> vector of annotation values
    4. (char) -> vector of annotation values
    
    While wanting to get the annotations of a substring, it became apparent
    that it behaved differently to fetching the annotations of an
    AnnotatedString{String}. This is undesirable. Upon further reflection,
    the diversity of return types when calling annotations on a string-like
    form is excessive, and behaviours 1-3 can be merged into a single
    behaviour, resulting in a simpler set of combinations:
    
    1. (string-like, region/index?) -> vector of region-annotation tuples
    2. (char) -> vector of annotation values
    
    I consider this simplification highly desirable.
    
    Since this changes the API, the usage in StyledStrings is also updated
    to match, and we bump the version of StyledStrings to get the new
    version compatible with this revised API.
    tecosaur committed Feb 11, 2024
    Configuration menu
    Copy the full SHA
    acbe35e View commit details
    Browse the repository at this point in the history