Add new public functions unsafe_substring
and unannotate
#59663
+121
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit includes several, interlocked changes:
unsafe_substring
, which creates a substring without checking for valid string indices. This new function is used in place of the old removed method, internally in Julia.unannotate
, which gives the underlying non-annotated string of anAnnotatedString
orSubString{AnnotatedString}
. The reason for this change is that currently, code outside Base (namely, in StyledStrings and JuliaSyntaxHighlighting) relies on this operation. Its current implementation reaches into bothAnnotatedString
andSubString
internals. Instead, I provide the function here in Base, and let the two stdlibs use it. Also in general, I think it's a completely reasonable basic function to have for annotated strings.For reviewers: We can make these functions exported (I don't have a strong opinion on that).
For this PR to land, it also requires compatible PRs in StyledStrings.jl and JuliaSyntaxHighlighting.jl, which uses the removed constructor.
This depends on two PRs to be merged first:
unannotate
function JuliaSyntaxHighlighting.jl#13unannotate
StyledStrings.jl#125Supersedes #59606
Closes #59610