IDEA-173487 New "Find in Path" dialog loses "File mask" dropdown history

Now completion popup with history is being shown when the field gets focus
This commit is contained in:
Vassiliy.Kudryashov
2017-05-27 15:53:16 +03:00
parent 5bb6012fcf
commit 104ce2210b
4 changed files with 20 additions and 1 deletions
@@ -56,6 +56,7 @@ public class AutoPopupController implements Disposable {
* This doesn't affect other conditions when autopopup is not possible (e.g. power save mode).
*/
public static final Key<Boolean> ALWAYS_AUTO_POPUP = Key.create("Always Show Completion Auto-Popup");
public static final Key<Boolean> ALWAYS_AUTO_POPUP_NO_ADS = Key.create("Always Show Completion Auto-Popup");
private final Project myProject;
private final Alarm myAlarm = new Alarm();
@@ -103,7 +104,7 @@ public class AutoPopupController implements Disposable {
return;
}
boolean alwaysAutoPopup = editor != null && Boolean.TRUE.equals(editor.getUserData(ALWAYS_AUTO_POPUP));
boolean alwaysAutoPopup = editor != null && (Boolean.TRUE.equals(editor.getUserData(ALWAYS_AUTO_POPUP)) || Boolean.TRUE.equals(editor.getUserData(ALWAYS_AUTO_POPUP_NO_ADS)));
if (!CodeInsightSettings.getInstance().AUTO_POPUP_COMPLETION_LOOKUP && !alwaysAutoPopup) {
return;
}
@@ -16,6 +16,7 @@
package com.intellij.codeInsight.lookup.impl;
import com.intellij.codeInsight.AutoPopupController;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
@@ -682,6 +683,9 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
}
myAdComponent.showRandomText();
if (Boolean.TRUE.equals(myEditor.getUserData(AutoPopupController.ALWAYS_AUTO_POPUP_NO_ADS))) {
myAdComponent.clearAdvertisements();
}
myUi = new LookupUi(this, myAdComponent, myList, myProject);
myUi.setCalculating(myCalculating);
@@ -16,6 +16,7 @@
package com.intellij.find.impl;
import com.intellij.CommonBundle;
import com.intellij.codeInsight.AutoPopupController;
import com.intellij.find.*;
import com.intellij.find.actions.ShowUsagesAction;
import com.intellij.icons.AllIcons;
@@ -29,6 +30,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -311,6 +313,13 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
super.setEnabled(enabled);
setBackground(enabled ? JBColor.background() : UIUtil.getComboBoxDisabledBackground());
}
@Override
protected EditorEx createEditor() {
EditorEx editor = super.createEditor();
editor.putUserData(AutoPopupController.ALWAYS_AUTO_POPUP_NO_ADS, Boolean.TRUE);
return editor;
}
};
myFileMaskField.setPreferredWidth(JBUI.scale(100));
myFileMaskField.addDocumentListener(new DocumentListener() {
@@ -15,6 +15,7 @@
*/
package com.intellij.util.textCompletion;
import com.intellij.codeInsight.AutoPopupController;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.IdeActions;
@@ -69,6 +70,10 @@ public class TextCompletionUtil {
editor.addFocusListener(new FocusChangeListener() {
@Override
public void focusGained(final Editor editor) {
if (Boolean.TRUE.equals(editor.getUserData(AutoPopupController.ALWAYS_AUTO_POPUP_NO_ADS))) {
AutoPopupController.getInstance(editor.getProject()).scheduleAutoPopup(editor);
return;
}
if (toShowHintRef.get() && editor.getDocument().getText().isEmpty()) {
ApplicationManager.getApplication().invokeLater(
() -> HintManager.getInstance().showInformationHint(editor, "Code completion available ( " + completionShortcutText + " )"));