WEB-66965 Getting types from TS Server blocks typing - add a reasonable timout for getting descriptors.

GitOrigin-RevId: f1dd1383e61980ac3e290daebdc2e77bbe5fd0ba
This commit is contained in:
Piotr Tomiak
2024-05-09 15:32:13 +02:00
committed by intellij-monorepo-bot
parent b3ad56c1a2
commit 392e797352

View File

@@ -20,12 +20,14 @@ import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.htmlInspections.XmlEntitiesInspection;
import com.intellij.lang.ASTNode;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
@@ -210,7 +212,19 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
}
}
XmlAttributeDescriptor[] attributes = descriptor.getAttributesDescriptors(tag);
XmlAttributeDescriptor[] attributes;
if (ApplicationManager.getApplication().isHeadlessEnvironment() || ApplicationManager.getApplication().isUnitTestMode()) {
attributes = descriptor.getAttributesDescriptors(tag);
}
else {
// Try not to block EDT for a long time
attributes = ProgressIndicatorUtils.withTimeout(500, () -> descriptor.getAttributesDescriptors(tag));
}
if (attributes == null || attributes.length == 0) {
return null;
}
StringBuilder indirectRequiredAttrs = null;
if (WebEditorOptions.getInstance().isAutomaticallyInsertRequiredAttributes()) {