-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support language-server arguments in the extension. #5056
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this converts
--foo="bar baz"
to two arguments:--foo="bar
andbaz"
, because the regex will greedily pick the longest match starting with the-
; that seems surprising to me. If we exclude'
and"
from the\S
, we'd get--foo=
andbar baz
, which still seems surprising to me but is closer to what I'd expect.Maybe we could match
"([^"]*)"|'([^']*)'|([^'"\s]+)|(\s+)
, and append to the current argument in the first three cases and start a new argument in the fourth case?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.
Note for
--foo="bar baz
(no closing quote), the suggestion would fail [silently, discarding args]. In the current code, it falls under the\S
case -- but if you keep the\S
case, your concatenation approach won't work.I understand it's not perfect, but I'm also not familiar enough with typescript to fix this quickly. Let me know if you'd prefer I close the PR, or if you can suggest code.
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.
OK, maybe just add a TODO for now, then.
Is there any reasonable way to add a test for this?
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.
Ended up spending enough time on this that I just figured out a different approach which should work.
Bazel doesn't seem to be prioritizing js/ts support, and I'm not sure what your "reasonable" threshold is.
There's https://github.com/aspect-build/rules_js and https://github.com/aspect-build/rules_ts, but they're not well-aimed at our use-case of having just a little ts buried in the repo here and there. I've considered investing time into figuring that out, have occasionally banged my head against bazel for a couple hours trying to figure out a good setup (now including today), but so far I've instead tried to keep the amount of JavaScript/TypeScript as niche as possible (now including today). My guess is that with a couple days I could probably figure out something to have a unit test for this code -- but it's not trivial, and I suspect it'd be fragile. I continue to hope that someone more fluent in ts and bazel will come along and clean up.
TBH if I could find an easy library to parse the args, I would. But quick searches were turning up advice on how to just write it myself.