Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Summary

<!--
Enter a 1-3 sentence description of this PR in this section. This should be
an overview of the bug and/or motivation for the changes. No implementation
details.

If this PR fixes an issue in the issue tracker, add a final one-sentence
paragraph to this section of the from `Fixes #xxx`, where "xxx" is the issue
number.
-->

## Details

<--
Start with 1-2 sentences describing *what* has changed, e.g. the "how" the
change was implemented. If the change set is small and straightforward, this
is all that's needed in this section.

If it's a more complex change, or modifies a lot of files, also include a
bulleted list that highlights important changes in the PR. Note this doesn't
have to be a huge list, but should include anything noteworthy or that should
not be missed by a reviewer.
-->

## Test plan

<--
Add any manual tests that should be performed to verify this fix before
merging. If there are none, this entire section can be omitted.
-->
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ public void insertUpdate(DocumentEvent e) {
justInserted = false;
if (isAutoCompleteEnabled() && isAutoActivationEnabled() &&
e.getLength() == 1) {
if (textComponent != null && provider.isAutoActivateOkay(textComponent)) {
if (textComponent != null && provider.isAutoActivateOkay(textComponent, e.getOffset())) {
timer.restart();
justInserted = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,21 @@ public interface CompletionProvider {
/**
* This method is called if auto-activation is enabled in the parent
* {@link AutoCompletion} after the user types a single character. This
* provider should check the text at the current caret position of the
* provider should check the text at the offset just inserted into the
* text component, and decide whether auto-activation would be appropriate
* here. For example, a <code>CompletionProvider</code> for Java might
* want to return <code>true</code> for this method only if the last
* character typed was a '<code>.</code>'.
*
* @param tc The text component.
* @param offs The offset of the character just inserted into the text
* component. This is passed explicitly, rather than being
* derived from the text component's caret position, since the
* caret is not guaranteed to have been updated yet when this
* method is called.
* @return Whether auto-activation would be appropriate.
*/
boolean isAutoActivateOkay(JTextComponent tc);
boolean isAutoActivateOkay(JTextComponent tc, int offs);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ public CompletionProvider getParent() {


@Override
public boolean isAutoActivateOkay(JTextComponent tc) {
public boolean isAutoActivateOkay(JTextComponent tc, int offs) {
Document doc = tc.getDocument();
char ch = 0;
try {
doc.getText(tc.getCaretPosition(), 1, s);
doc.getText(offs, 1, s);
ch = s.first();
} catch (BadLocationException ble) { // Never happens
ble.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ public CompletionProvider getStringCompletionProvider() {


@Override
public boolean isAutoActivateOkay(JTextComponent tc) {
public boolean isAutoActivateOkay(JTextComponent tc, int offs) {
CompletionProvider provider = getProviderFor(tc);
return provider != null && provider.isAutoActivateOkay(tc);
return provider != null && provider.isAutoActivateOkay(tc, offs);
}


Expand Down
Loading