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

Send replacement spans in response, fixes a whole class of issues #156

Merged
merged 2 commits into from Dec 6, 2021
Merged

Send replacement spans in response, fixes a whole class of issues #156

merged 2 commits into from Dec 6, 2021

Conversation

jasonwilliams
Copy link
Contributor

@jasonwilliams jasonwilliams commented Nov 20, 2021

Well that was a long journey....
But I think I've managed to fix it.

working.2.mp4

After some long debugging I was able to see that replacementSpans weren't being sent to VSCode. Causing VSCode falling back to defaultSpans which weren't very good. Basically it was falling back to appending the value on the end instead of replacing the word left of the cursor. This problem is 2-fold because VSCode uses the replacement span information to know how to filter-down the results the language server sends. So results in the UI were also bad because of there being no spans

The offset being sent was wrong, I was able to figure out that it was off by 7 characters which coincidently is the same length of the document wrapper, so I have deducted that which gives much better results.

Fixes: styled-components/vscode-styled-components#322
Fixes: microsoft/vscode#134328 (comment)
Fixes: styled-components/vscode-styled-components#325
Fixes: styled-components/vscode-styled-components#302
Fixes: #155
Fixes: #141
Fixes: #153

I need a lie down now

@mjbvz hopefully you can take a look at this

@karlhorky
Copy link

Amazing deep dive @jasonwilliams, thanks so much for this!! This will improve UX so much!

@jasonwilliams
Copy link
Contributor Author

Ping @mjbvz

@mjbvz mjbvz merged commit 580be8a into microsoft:main Dec 6, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Dec 6, 2021

Thanks! The change looks good to me so I'm merging and will publish a new build shortly

(sorry for the delay, was out on vacation for the past two weeks)

@mjbvz
Copy link
Contributor

mjbvz commented Dec 6, 2021

Great work with the investigation BTW! Weird issue so I'm glad you found a fix

@isra2021
Copy link

use the official plugin for styled-components

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.