-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: autocomplete brackets #46
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
Conversation
Qodana Community for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.2.1
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
I think it should be done with a lexer and brackets pair mechanism, what do you think?
Is it what users expect? and should it be done this way? |
Ideally, yes, however it'd make things quite a lot more complex. I also have no experience with multi-character bracket matching, IntelliJ's brace matching model is single-token based. I could use a bit of help here.
Not necessarily, but I personally find it a nice and quick way of replacing both brackets at once. Might need a bit of getting used to, though.
We could possibly let the users decide? We could add some kind of option to the menu and the user could choose whether they want automatic bracket changing (marked as CPU intensive like Laravel Idea does with some features) or not. What do you think? |
|
I actually really like this feature, it's something I've often missed in Blade. For me personally, having this indeed removes the need for a context action, but I reckon that action will still be useful to others. Of course, if it's performant enough. |
I'll add actions as well, then, and I'll make it so you can opt-out from the auto-bracket-matching feature via settings if it'd be too CPU-heavy on your machine. As for the lexer part, I'll still need a bit of help with that. @xepozz 👀 It could also come in a next iteration, just so in the meantime users of the plugin could enjoy the feature as-is. |
xepozz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
com.github.tempest.framework.views.completion.TemplateBracketBackspaceHandler doesn't seem to work
I'd suggest to remove it at all.
As for closing pairs I'd suggest to implement it as the following:
- placing
{adds another}without any doubt - placing
!or-after{{doubles the char and places doubled chars before the closing}} - placing a space adds another one, the same as you did
Regarding implementation, I'd suggest to use indexes instead of toString() and positional checks.
src/main/kotlin/com/github/tempest/framework/views/completion/TemplateBracketTypedHandler.kt
Show resolved
Hide resolved
src/main/kotlin/com/github/tempest/framework/views/completion/TemplateBracketTypedHandler.kt
Outdated
Show resolved
Hide resolved
Are you sure? It works for me.
|
|
Looks good. Thanks for improving. Feel free to merge if you're done |
Closes #21.
Cursor in the example is
|.Typing
{{|will produce{{|}}. Same with{{!!and{{--.Upon pressing space with the cursor like this:
{{|}}it will be expanded to{{ | }}instead of{{ |}}for ergonomics.Additionally, modifying the opening bracket modifies the closing bracket as well. For example if you have
{{ $variable }}and you change the opening bracket to{{!!, the closing bracket will also reflect the change and the line becomes{{!! $variable !!}}.