Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java32
2 files changed, 32 insertions, 16 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index 7d077f2bb..c60a3ec6f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -355,9 +355,10 @@ class CompletionProposalPopup implements IContentAssistListener {
int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
List<ICompletionProposal> proposals= null;
+ DocumentEvent event= null;
try {
if (offset > -1) {
- DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
+ event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
proposals= computeFilteredProposals(offset, event);
}
} catch (BadLocationException x) {
@@ -368,8 +369,19 @@ class CompletionProposalPopup implements IContentAssistListener {
if (proposals != null && proposals.size() > 0)
setProposals(proposals, fIsFilteredSubset);
- else
+ else {
hide();
+ if (fContentAssistant.isAutoActivation() && offset > 0 && event != null) {
+ try {
+ char charBeforeOffset= event.getDocument().getChar(offset - 1);
+ if (fContentAssistant.isAutoActivationTriggerChar(charBeforeOffset)) {
+ fContentAssistant.fireSessionBeginEvent(true);
+ showProposals(true);
+ }
+ } catch (BadLocationException e) {
+ }
+ }
+ }
}
};
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index 7c614d561..2e3ed84a7 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -323,7 +323,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
// Only act on characters that are trigger candidates. This
// avoids computing the model selection on every keystroke
- if (computeAllAutoActivationTriggers().indexOf(e.character) < 0) {
+ if (!isAutoActivationTriggerChar(e.character)) {
stop();
return;
}
@@ -935,7 +935,8 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private Closer fCloser;
LayoutManager fLayoutManager;
- private AutoAssistListener fAutoAssistListener;
+
+ AutoAssistListener fAutoAssistListener;
private InternalListener fInternalListener;
private CompletionProposalPopup fProposalPopup;
private ContextInformationPopup fContextInfoPopup;
@@ -1183,27 +1184,26 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
/**
- * Computes the sorted set of all auto activation trigger characters.
- *
- * @return the sorted set of all auto activation trigger characters
- * @since 3.1
+ * @return whether the given char is an auto-activation trigger char
+ * @since 3.15
*/
- private String computeAllAutoActivationTriggers() {
+ boolean isAutoActivationTriggerChar(char c) {
if (fProcessors == null)
- return ""; //$NON-NLS-1$
+ return false;
- StringBuilder buf= new StringBuilder(5);
for (Set<IContentAssistProcessor> processorsForContentType : fProcessors.values()) {
for (IContentAssistProcessor processor : processorsForContentType) {
char[] triggers= processor.getCompletionProposalAutoActivationCharacters();
- if (triggers != null)
- buf.append(triggers);
+ if (triggers != null && new String(triggers).indexOf(c) >= 0) {
+ return true;
+ }
triggers= processor.getContextInformationAutoActivationCharacters();
- if (triggers != null)
- buf.append(triggers);
+ if (triggers != null && new String(triggers).indexOf(c) >= 0) {
+ return true;
+ }
}
}
- return buf.toString();
+ return false;
}
/**
@@ -2783,4 +2783,8 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
public void enableCompletionProposalTriggerChars(boolean enable) {
fCompletionProposalTriggerCharsEnabled= enable;
}
+
+ boolean isAutoActivation() {
+ return fIsAutoActivated;
+ }
}

Back to the top