Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

CSS suggestions get dropped off when converting up into TypeScript completion items #132

Closed
jasonwilliams opened this issue Apr 28, 2021 · 6 comments

Comments

@jasonwilliams
Copy link
Contributor

Hi @mjbvz
I was looking into fixing the colon and semiColon auto completion which has been raised in styled-components

I came across completion items, which i assumed I can add a command property to, but it seems they're converted to completionEntrys which seems to be a typescript thing.
https://github.com/microsoft/typescript-styled-plugin/blob/main/src/_language-service.ts#L382-L395

CompletionEntrys look similar to CompletionItems but don't have a command property (Im assuming they need to be generic).

Do you know what's happening here? And does this make the above task not possible?

@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented Apr 28, 2021

I added some code actions to

return {
name: item.label,
kind: item.kind ? translateCompletionItemKind(typescript, item.kind) : typescript.ScriptElementKind.unknown,
kindModifiers: getKindModifiers(item),
displayParts: toDisplayParts(item.detail),
documentation: toDisplayParts(item.documentation),
tags: [],
};
but nothing seems to have happened on the UI side

@jasonwilliams jasonwilliams reopened this Apr 28, 2021
@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented May 2, 2021

Hey @aeschli, messaging you because it looks like you've dealt with this before.
It seems CompletionItems coming up from cssLanguageService have commands attached to them. But once they go through translateCompetionEntry they get dropped off. Mainly because CompletionEntry doesn't have an equivalent.

This means we're losing codeActions and commands coming up from CSS Language Service.
Is there a way to rectify this? Does the interface need changing?

Here (line 126) items have codeActions and Commands, but once they go through 137 all that has gone.

@jasonwilliams jasonwilliams changed the title Add a colon and semicolon, as well as trigger property value completion after rule name completion CSS suggestions get dropped off when converting up into TypeScript completion items May 2, 2021
@aeschli
Copy link

aeschli commented May 2, 2021

The command that we add to the css completions is 'editor.action.triggerSuggest`. It opens code completion again after a proposal is applied. For example when a property is competed, the user can complete the values right away.

I think you would have to convince the TypeScript guys to adopt the feature (at least a 'regtrigger' flag). Looking at the current API I don't see any tricks to achieve this. Even if there were, it would have to to be adopted in our TypeScript client.
Maybe @mjbvz knows more.

On the css side you can turn off the addition of command (document settings: completion.triggerPropertyValueCompletion), I would suggest to also turn off the semicolon after the completion (completion.completePropertyWithSemicolon) so this looks a bit cleaner

@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented May 3, 2021

I think you would have to convince the TypeScript guys to adopt the feature (at least a 'regtrigger' flag). Looking at the current API I don't see any tricks to achieve this. Even if there were, it would have to to be adopted in our TypeScript client.
Maybe @mjbvz knows more.

@aeschli what's the reason TypeScript's language server interface have restricted commands in ts.CompletionEntry, is that not needed? I thought typescript would need this for their own language server? From what I understand there's no way to pass a completionItem's command back up to VSCode?

you would have to convince the TypeScript guys to adopt the feature

I wouldn't even know where to start in bringing that up as a feature request, It seems like the interfaces need adjusting and the TypeScript client would need changing to receive the commands? Maybe there's more to it than that.

On the css side you can turn off the addition of command (document settings: completion.triggerPropertyValueCompletion), I would suggest to also turn off the semicolon after the completion (completion.completePropertyWithSemicolon) so this looks a bit cleaner

Not sure I'm with you here, our issue is the command isn't happening at all, not that we want to turn it off. Do you mean once we've implemented it ourselves there would be conflicts?

@aeschli
Copy link

aeschli commented May 3, 2021

Commands on completions are quite an advanced feature, and is, to my knowledge, used only rarely. It's also not very clean as for this to work across editors it would require to define a set of known commands.
As said, for 'retrigger' it would be much better to have this more explicit as a flag (`retrigger') on the completion proposal.

Unfortunately TypeScript's API types and VSCodes API types are quite different for historical reasons.
As said, I would suggest to file an issue against TypeScript for them to support a 'retrigger' property on the proposal.

@mjbvz
Copy link
Contributor

mjbvz commented Apr 4, 2023

Closing as this package has been deprecated in favor of the official styled-components/typescript-styled-plugin fork

After updating to that fork, follow up in the styled-components repo if this is still an issue

@mjbvz mjbvz closed this as completed Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants