Syntax Test: scope autocompletion
I am writing my first syntax_test file with PackageDev and I am impressed of the features supporting my work. Great job.
However one idea was born how to possibly improve user experience further.
If a ^ is typed in a comment, all scopes of the column of tested line are added to the view. I would like to be able to select only one of them.
So could you display the auto-completion list which lists all scopes if a user types ^ instead of pasting all to the view?
I usually just select the part of the completed scope I don't want and delete that. That's at least the most flexible way.
However, I'll see if using the auto complete popup works well here. Probably not too soon since I should be working on the remaining syntaxes to finally get 3.0.0 out. :wink:
Going through some issues again, do you have a suggestion on the UX side here? I'm having a hard time thinking of a general approach that will result in an overall better experience than what we have currently. It's very hard to programatically decide which parts of the scopes you actually need and it's much worse to remove too many scope segments as it's much more work to readd those compared to deleting a couple.
I was thinking of an input handler where you can un/select the scope that you would want to keep (with shortcuts to (un-)select until or after a certain fragment). That would also allow a preview of the current scope name, but I have doubts on the implementation. ST isn't that good with interactive interfaces and I wonder how fluently I could pull this off.
Also it must still be possible to insert more ^ to enlarge the test area, but that's probably not too much of an issue.
Maybe it's okay to delete a prefix that's strictly redundant with another test above. Current:
// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax"
[a, b, c, d]
//^^^^^^^^^^^^ meta.sequence
//^ meta.sequence punctuation.section.brackets.begin
Proposed:
// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax"
[a, b, c, d]
//^^^^^^^^^^^^ meta.sequence
//^ punctuation.section.brackets.begin
We're sure the user doesn't need the extra meta.sequence because they're already testing for it in the line above.
Maybe a completion panel with all scopes of the line may be displayed when pressing ^ + space, or space at the end of the testcase?
Regarding to the examples in the previous post, it would mean to display a completion panel with meta.sequence and punctuation.section.brackets.begin rather than adding all scopes at the same time.
If the cursor is moved after meta.sequence and space is pressed, the completion panel could be displayed again with the remaining scopes.
Forthermore the normal scope completion which is used in the sublime-syntax files could be applied as well, so if you need to write a "negative" rule whose scope is not part of the tested line can be written with the same level of support as in the original syntax.
I like that. Sounds simpler to manage than an input handler, albeit handling the the completions popup in sublime-syntax is a bit hacky. On the other hand, it is proven to work and when the panel is properly reopened it ends up working like tab -> tab -> down arrow -> down arrow -> tab -> escape and you get the scope segments 1, 2, 5.
I believe this should be tested first.
(And with the proper setting you can even cycle the completions list, unlike in quick panels!)