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 syntax_test shortcut for first character of previous line #382

Open
nk9 opened this issue Dec 14, 2022 · 1 comment
Open

Add syntax_test shortcut for first character of previous line #382

nk9 opened this issue Dec 14, 2022 · 1 comment
Assignees

Comments

@nk9
Copy link

nk9 commented Dec 14, 2022

If you press Tab in a syntax_test_* file on a line that has the test prefix (# in my case), it jumps to the next column, adds carets and the appropriate scopes. I've also found that when you use ^, you can step through the meta scopes, and once the meta scopes are added to a line's tests, subsequent auto-generated tests exclude it, thus making them much more readable. This is great, and dramatically speeds up writing tests when you have a syntax file that's working correctly.

But Tab finds the last column n with a test of any sort from the previous line and starts the next test in column n+1. That means that you can easily insert a meta test with something like #^^^, but then you have to manually line up the next test using Shift+Tab to get Tab working again to easily insert more tests.

So in this situation, with the cursor at |, I want a new, single-character test added at % for the open paren:

a = myfunc("param1", var2) + 3
#         ^^^^^^^^^^^^^^^^ meta.function-call.arguments.python
#|        %

Possible ways to address this:

  1. Add a shortcut that would work like Tab when adding a new assertion, but would still add a test to the first un-asserted substring of the meta scope region if the previous line only contains meta scopes.
  2. Simpler, just add a shortcut which works like Tab but instead of thinking about whether the previous region is meta or not, just start looking for the next range at the beginning of the previous line's assertion region.

I guess a good default binding for this shortcut on Mac would be Opt+Tab, although I don't know what would work best on Windows.

But another possibility is to just have Tab always work like proposal 1 above. That way it would be easy to find, and would encourage comprehensive testing. In this case, maybe we'd want to change the present behavior to another function/binding so that it was still available if needed.

@FichteFoll
Copy link
Member

FichteFoll commented May 6, 2023

So, I just realized that my caret actually ends up at what you denoted as % at the moment, which is probably why this never bothered me. Turns out this was caused by DocBlockr, which also inserts a comment marker on the next line. So for now, installing a plugin that provides a similar functionality will already provide you with this feature.

However, I believe especially considering that the syntax text marker may not necessarily also be the one to denote comments, it makes sense for PD to provide this functionality by itself. Not a high priority, though.

@FichteFoll FichteFoll self-assigned this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants