Upstream issue: https://youtrack.jetbrains.com/issue/KT-21420
When opening a .gradle.kts file, it is first shown with an editor that do no semantic highlighting while IJ is doing some indexing.
Then, it is shown with semantic highlighting before the editor has a chance to get the response from the script template dependency resolver. But the semantic highlighting fails and the editor is "all red".
Then, once the dependency resolver response is received, semantic highlighting finally works.It is very confusing to users as IJ tell them their script is full of errors when it is not, it's just that IJ doesn't have all the necessary context yet.
This issue is about preserving the state of the editor without context (in which it doesn't do semantic highlighting including errors) until the first successful dependency resolver response.
Please find attached an animated gif showing the current behaviour. It is quite long despite me pausing the recording while IJ is indexing but it shows the 3 steps clearly: first no semantic highlighting, then all red, then all fine.

This has annoyed me for so long. That description is amazing. I'm glad to be seeing it get fixed!!
Yep, took time to understand what's happening. It has been reported upstream, let's hope it'll get fixed in a reasonable time frame.
Marked as fixed upstream and targeted at Kotlin 1.2.40 \o/
\o/
Confirmed as fixed in 1.2.40-eap-16
Most helpful comment
Confirmed as fixed in 1.2.40-eap-16