TextFieldWithAutoCompletion Not Showing Suggestions on Pasted Content: Seeking Solution

Answered

When using com.intellij.ui.TextFieldWithAutoCompletion for auto-completion, I'm encountering an issue where the drop-down suggestions do not display when content is pasted into the text field. Is there a known workaround or configuration I can adjust to ensure that the auto-completion suggestions are triggered even when pasting content?

0
3 comments

List<String> strings = Lists.newArrayList("1", "2", "3", “4”, “5”);

TextFieldWithAutoCompletion<String> completion = TextFieldWithAutoCompletion.create(project, strings, false, "");
TextFieldWithAutoCompletion.StringsCompletionProvider stringsCompletionProvider = 

new TextFieldWithAutoCompletion.StringsCompletionProvider(strings, null);
completion.installProvider(stringsCompletionProvider);
completion.setPreferredSize(new Dimension(100, 30));
completion.setBorder(BorderFactory.createEmptyBorder());
completion.setVisible(true);
completion.addDocumentListener(new DocumentListener() {
  @Override
  public void beforeDocumentChange(@NotNull DocumentEvent event) {
    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> beforeDocumentChange");
  }
});

 

How to trigger a dropdown prompt when text changes?

 

0

You can try with AutoPopupController.getInstance(project).scheduleAutoPopup(completion.getEditor()).

I would also try to call it in documentChanged, not beforeDocumentChange.

1

Thank you very much, it has been very useful to me

0

Please sign in to leave a comment.