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

Add command to autogenerate syntax tests for line of code. #341

Merged

Conversation

Thom1729
Copy link
Member

@Thom1729 Thom1729 commented Mar 13, 2021

Example:

// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax"

    if ( true ) { }

Result (with "syntax_test.suggest_scope_suffix": false):

// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax"

    if ( true ) { }
//  ^^^^^^^^^^^^^^^ meta.conditional
//  ^^ keyword.control.conditional.if
//     ^^^^^^^^ meta.group
//     ^ punctuation.section.group.begin
//       ^^^^ constant.language.boolean.true
//            ^ punctuation.section.group.end
//              ^^^ meta.block
//              ^ punctuation.section.block.begin
//                ^ punctuation.section.block.end

Could probably use a key binding or something, but the implementation should be pretty much good.

@Thom1729
Copy link
Member Author

I added some code to make some tests for nested scopes more compact.

Before:

    42
//  ^^ meta.number.integer.decimal
//  ^^ constant.numeric.value

After:

    42
//  ^^ meta.number.integer.decimal constant.numeric.value

@FichteFoll
Copy link
Member

That looks really nice. I'm going to give this a test run in hopefully the next week and work on another release.

Just wondering how we could make this command more accessible than just in the command palette without being obstrusive.

@FichteFoll FichteFoll added this to the 3.3.2 milestone Mar 20, 2021
@Thom1729
Copy link
Member Author

Thom1729 commented Mar 20, 2021

I think it would make sense to bind it to control-enter or something. Do we have a context key for determining whether the view is a syntax test? If not, it would be easy to add. I see that there is one.

@FichteFoll FichteFoll merged commit 2653557 into SublimeText:master Feb 26, 2022
@FichteFoll
Copy link
Member

FichteFoll commented Feb 26, 2022

The compacting code didn't work for me, but after some fiddling I was able to find the bugs and squash them. This will be included in the next release. I'm working on the changelog already. 🚀

2022-02-27_00-32-31.mp4

Edit: no release today, though

@Thom1729 Thom1729 deleted the generate-syntax-tests-for-line branch March 12, 2022 16:58
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.

2 participants