[ui] fix selection when editor is not fully initialized

related to IDEA-335018 and needed for WI-27593

GitOrigin-RevId: b531e27b144c547b7e97d8f5168c137e2f1c3221
This commit is contained in:
Artemy Pestretsov
2023-10-27 16:52:38 +02:00
committed by intellij-monorepo-bot
parent b1c0963942
commit 89626af21e

View File

@@ -120,11 +120,10 @@ public class NameSuggestionsField extends JPanel {
public void select(final int start, final int end) {
SwingUtilities.invokeLater(() -> {
Editor editor = getEditor();
if (editor == null) return;
editor.getSelectionModel().setSelection(start, end);
editor.getCaretModel().moveToOffset(end);
EditorTextField textField = getEditorTextField();
if (textField == null) return;
textField.select(TextRange.create(start, end));
textField.setCaretPosition(end);
});
}