Skip to content

For 5.0.0: Rename HighlightLines::highlight() to highlight_line()#406

Merged
trishume merged 3 commits into
trishume:masterfrom
Enselic:rename-highlight-to-highlight_line
Jan 17, 2022
Merged

For 5.0.0: Rename HighlightLines::highlight() to highlight_line()#406
trishume merged 3 commits into
trishume:masterfrom
Enselic:rename-highlight-to-highlight_line

Conversation

@Enselic

@Enselic Enselic commented Jan 3, 2022

Copy link
Copy Markdown
Collaborator

To make it clear that the function takes one line at a time.

This require a semver major bump, but we need to do that anyway due to the
syntax lazy-loading changes.

Fixes #314

To make it clear that the function takes one line at a time.

This require a semver major bump, but we need to do that anyway due to the
syntax lazy-loading changes.

Fixes trishume#314
@Enselic Enselic force-pushed the rename-highlight-to-highlight_line branch from 89733f0 to 273e0f4 Compare January 3, 2022 10:30
@Enselic

Enselic commented Jan 3, 2022

Copy link
Copy Markdown
Collaborator Author

@epage Would you mind taking a look at this fix for #314 since you filed that issue? Big thanks in advance.

@epage

epage commented Jan 3, 2022

Copy link
Copy Markdown

Looks good. Thanks!

@Enselic

Enselic commented Jan 3, 2022

Copy link
Copy Markdown
Collaborator Author

Big thanks for taking a look.

(I will move out the CHANGELOG.md changes into a separate PR to avoid conflicts with other upcoming PRs.)

@trishume

Copy link
Copy Markdown
Owner

Can you change this to a deprecation of the old name? I know it's a major version bump so we can just remove it, but this is the biggest API change and deprecations are way friendlier then renames given that the compile error can directly tell the user how to rename their call. It'll make upgrading to the new major version much smoother.

Maybe the warning can even be like "highlight was renamed to highlight_line to make it clear it should be passed a single line at a time"

@Enselic

Enselic commented Jan 16, 2022

Copy link
Copy Markdown
Collaborator Author

Sure, no problem at all. I have pushed a commit to fix that.

Here is how the deprecation message looks in the wild. (Generated by temporarily using the deprecated variant in our own example code.)

warning: use of deprecated associated function `syntect::easy::HighlightLines::<'a>::highlight`: Renamed to `highlight_line` to make it clear it should be passed a single line at a time
   --> examples/syncat.rs:106:83
    |
106 |                     let regions: Vec<(Style, &str)> = highlighter.highlight_lines.highlight(&line, &ss);
    |                                                                                   ^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

@trishume trishume merged commit 512b73e into trishume:master Jan 17, 2022
@Enselic Enselic deleted the rename-highlight-to-highlight_line branch February 23, 2022 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename HighlightLines::highlight() to highlight_line() for clarity

3 participants