Implement remaining sublime-syntax Build 4075 features#612
Conversation
- v2 set + clear_scopes: allow set operations to apply clear_scopes - v2 embed_scope replacement: embed_scope replaces embedded syntax scope - Multiple inheritance: extends accepts a YAML list of syntax paths
Remove derived PartialOrd and implement it manually so that PartialOrd delegates to Ord, following the standard pattern for types with a total ordering. This resolves a hard lint error introduced by Rust 1.92's clippy that was not suppressed by the previous #[allow] attribute placement.
…ring> None and Some(vec![]) are never semantically distinct: the YAML parser already converts empty arrays to None, and all consumption sites treat both identically. Replace the Option wrapper with a plain Vec, using an empty vec to mean "no extends".
There was a problem hiding this comment.
This failed for me on CI, although I couldn't repro locally. Not sure of what's wrong.
There was a problem hiding this comment.
To clarify, the only reason why I added this comment is to make sure it was clear why I edited this (seemingly unrelated) file. @jrappen also raised that it appears to be a problem on master as well here. As mentioned elsewhere, this is already take care of in a2d1823. Not sure how this creeped into master TBH, this check passed on #610 IIUC.
This comment was marked as resolved.
This comment was marked as resolved.
There's no need, I only added the comment to make sure it was clear why I made the change. The error is the same that you raised in #610 (comment) and that I fixed in a2d1823.
Are you saying this pointing to some specific flaw in the PR? |
This comment was marked as resolved.
This comment was marked as resolved.
Cover the remaining Build 4075 compatibility items raised by jrappen: v1/v2 behavioral differences: - B: v2 set action should not apply parent meta_content_scope to matched text (currently FAILS — implementation gap) - D: v2 embed escape text should get meta_scope of embed context (currently FAILS — not yet implemented) - E: v2 push with multiple targets applies clear_scopes only from the last context (PASSES — confirmed working) - F: capture group scopes are applied in text position order, not capture number order (PASSES — confirmed working) Multiple inheritance validation gaps: - G: all parents in extends must derive from the same base syntax (currently FAILS — no common-base validation) - H: parent and its base must share the same version (currently FAILS — no version consistency check) - I: source syntax and its parents must share the same version (currently FAILS — no version consistency check) Failing tests are left as-is to document unimplemented behavior for follow-up work.
- v2 set: pop parent meta_content_scope before matched text so it is not visible on the token, matching Sublime Build 4075 behavior - v2 embed escape: keep embed_scope (meta_content_scope) visible on the escape text itself; fix spurious scope pop caused by the with_prototype lookahead popping the embedded context whose mcs was never pushed - extends validation: reject extends when parent and child versions differ (H/I) or when multiple parents share no common base syntax (G)
|
Thanks for the detailed review!
I went through the compatibility list after your comment. The latest two commits add tests covering the remaining gaps I found and fix the ones that were failing: specifically,
The "exists" case was already covered: unresolvable parents cause the child to remain in the unresolved set, which produces a warning at the end of the fixed-point loop. The other three were missing — the latest commits add them:
In all error cases syntect emits a warning (via |
Reformat method chaining and function calls to meet rustfmt standards: - parser.rs: split ops.push() call across multiple lines - syntax_set.rs: convert .iter().position() chains to method-chaining style
Per Sublime Text docs, embed_scope applies to text "after the match and before the escape" — it should not apply to the escape text itself. The v2 embed_scope_replaces special case in the Pop path of push_meta_ops incorrectly kept the embed_scope (meta_content_scope) on the scope stack during escape text processing. This caused downstream highlighting regressions (e.g. Typst fenced code block closing backticks getting the embedded language's color instead of the default foreground). Remove the special case and let the normal pop logic handle it: pop meta_content_scope before the escape text (initial=true) and meta_scope after (initial=false). The skip check for embedded syntax contexts whose meta_content_scope was never pushed is preserved.
This comment was marked as resolved.
This comment was marked as resolved.
Verify that extends paths like "syntaxes/Child.sublime-syntax" resolve correctly against full loaded paths via suffix matching, confirming relative paths work without any code changes.
|
I hadn't thought about local relative paths explicitly. I looked into it, the current |
|
Is there some way in which I can facilitate the review process? 🙂 |
|
My comments above were addressed, marked them as "resolved". Looks good so far. |
|
@keith-hall maybe you can take a look if you have a min? |
Make progress on #323: