Closed Dima-369 closed 2 months ago
Hi @Dima-369 Can you please check if the behaviour in the video matches your expectations? On Windows, I use Ctrl+W to expand selection and Ctrl+Shift+W to shrink the selection.
I've tested this on the upcoming version 0.5.0, which I hope to deploy today or in the coming days
https://github.com/user-attachments/assets/b3f91c36-89f1-4250-8d69-dda57ac6013f
Can you please check if the behaviour in the video matches your expectations?
Yes, exactly! I am looking forward to 0.5.0 🙂
I tested the latest develop
and there this does not work?
https://github.com/user-attachments/assets/4c101eda-55b3-4b3c-b979-4e86b03bd93a
Oh! Yes, you're right. The correct behaviour only works with strings that only consist of one "word". Tbh I have no clue how this comes about, as I haven't implemented the feature myself, but comes with the IDE. I merely have to tell the framework which tokens are the String tokens. Maybe I made a mistake there.
Is it the same for all string literals?
Yeah, I tried with your example. Exactly, it is about the whitespace!
I tested with the ZigBrains plugin, and it exhibits the same 'bug' also present here.
Edit: Same with the Nim IntelliJ plugin.
It works in the Scala plugin for .scala
files, but there is no .bnf
file for their syntax to check against, apparently. Maybe this is a quirk with the lexer implementation in IntelliJ?
I checked a Kotlin file (where this also works correctly) with Show Editor Highlighter Tokens
enabled, and found that they treat the surrounding quotes as special tokens, which may help in fixing this?
I am very new to the .bnf
files, I suppose DQ_STRING_LITERAL='regexp:"[^"]*"'
may need changes for this?
Oh cool, good to know. This is a tough one though. It has to be done on Lexer basis, which is defined in Odin.flex. The fact the strings would not contain quotes anymore would also have a series of consequences in the grammar, which is defined in Odin.bnf.
However, I was just looking at the token structure of Java. There, they also don't have any special tokens for opening or closing quotes, but it still works. Hmmm, this might be a question for JetBrains.
FYI: The token definitions in Odin.bnf are merely for the Preview-Tool that I used in the beginning. But the grammar grew a lot in complexity with custom rules and parsing states. What I want to say: the regexes in Odin.bnf are meaningless. They are not used to create the tokens. Rather the lexer is created from Odin.flex
Anyway, ChatGPT knows it all. There is class called "ExtendWordSelectionHandler" which one can use to change the behaviour of extend/shrink selection.
Anyway, ChatGPT knows it all.
Hah, I also feel that way for the IntelliJ Plugin SDK stuff - googling anything about it is such a pain 😄
And that's cool, so we can achieve that behavior!
A pain indeed my friend! The nice thing is that the JetBrains guys really answer when posting a question on their issue tracker.
Ok, I think we got it now. I added OdinStringSelectioner that should take care of selecting to just before the quotes. Just pushed :)
I tested and indeed, it works perfectly for "
now! Thanks.
I would love it if raw string literals via ` would also be supported 😉
https://github.com/user-attachments/assets/875ce5fe-2bf5-45a9-95fc-8697010bd8f8
I tested and indeed, it works perfectly for
"
now! Thanks.I would love it if raw string literals via ` would also be supported 😉
CleanShot.2024-08-14.at.13.25.04.mp4
Ah yes, adding it. :)
Should be working now. I just publish the plugin to the JetBrains Marketplace. It will be accepted within 1-2 business days :) Thank you so much for helping with this release
FYI: I changed the Java version to 21, so you might have to change the project SDK to 21.
Should be working now.
I tested and it works great, thanks!
Thank you so much for helping with this release
Thank you as well for the superfast fixes.
I am happy that this plugin has become even more useful now! 🙂
I think on the next release I will focus on contextually correct code completion and refactorings. It is a pleasure to work with you. Feel free to join anytime you want
I am very used to the
Extend Selection
action in other programming languages, but I notice how it behaves a tad off for Odin.If the cursor is on the space in the string
a := "test string"
, expanding first selectstest
which is good, but the next invocation selects"test string"
with the quotes. In pretty much all other languages, it first proceeds to select everything inside the string first. So, I would expecttest string
(without quotes).This throws off my muscle memory a lot.