-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Normalize code actions indentation #20
Closed
Closed
Changes from all commits
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
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.
The way servers like
typescript-language-server
handle that is they ensure thatConfigure
request is always sent for the current file before getting code actions or doing other relevant requests. Is that not possible here?Line endings is just one of the aspects. There are also other formatting choices like whether to use spaces or not, whether to use semicolons etc. So this doesn't seem like a very comprehensive solution.
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.
@rchl I'm quite confused.
Since the package is intended for vscode only, we should never care about it, thats why it is always set to
\n
.Other format options are already used, the only issue was
formatOptions
that contains indentation informationnormalizeCodeActionEdit
only changes indentation, I'm replicating vscode behavior: https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts#L59-L62But you're right ideally it should be passed during request, but as I understood from vuejs/language-tools#2498 (comment) its currently not possible / no easy way to do it. Though, AFAICS from my use cases the current solution works ideally
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 was indeed confused about line breaks vs. indentation.
But the same point still stands that indentation style is just one of the options passed through the
Configure
request so ideally that request should be made.I don't know code base well enough to say whether it's feasible to do so from this point I'm just deferring to @johnsoncodehk to give his take and decide whether that's fine.
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 hope to avoid use middleware handling it, which causes other language clients to have to follow if they want the same functionality. I think it would be best to raise this requirement to the LSP repo. Also
replaceAll()
may break\t
in TemplateLiteral.If this feature is important, these two approaches may work:
tmpdir()
or similar to share it.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.
Isn't creating custom request such as sync format options much easier?
Though it is much easier to go with first way, so, let's infer code-style in place.
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.
Because custom request requires downstream language clients to implement, I hope to reduce the necessary work for the language clients.
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.
Done here: volarjs/services@65c2a15 so I'm closing this pr