1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Let users escape more easily from the autosuggester after typing "[" or "("

Summary:
Ref T13077. The autosuggester is a little too eager right now, and will eat carriage returns after typing `[` if you never activate the tokenizer.

To fix this, try just canceling sooner. If that doesn't work, we might need to cancel more eagerly by testing to see if the tokenizer is actually open.

Test Plan: Typed `[x]<return>`, got my return instead of getting trapped by the autosuggester.

Maniphest Tasks: T13077

Differential Revision: https://secure.phabricator.com/D19110
This commit is contained in:
epriestley 2018-02-16 11:00:03 -08:00
parent 0202c36b62
commit 8796a6036e
2 changed files with 20 additions and 20 deletions

View file

@ -528,7 +528,7 @@ return array(
'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9',
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
'rsrc/js/phuix/PHUIXActionView.js' => '442efd08',
'rsrc/js/phuix/PHUIXAutocomplete.js' => '623a766b',
'rsrc/js/phuix/PHUIXAutocomplete.js' => '7fa5c915',
'rsrc/js/phuix/PHUIXButtonView.js' => '8a91e1ac',
'rsrc/js/phuix/PHUIXDropdownMenu.js' => '04b2ae03',
'rsrc/js/phuix/PHUIXExample.js' => '68af71ca',
@ -881,7 +881,7 @@ return array(
'phui-workpanel-view-css' => 'a3a63478',
'phuix-action-list-view' => 'b5c256b8',
'phuix-action-view' => '442efd08',
'phuix-autocomplete' => '623a766b',
'phuix-autocomplete' => '7fa5c915',
'phuix-button-view' => '8a91e1ac',
'phuix-dropdown-menu' => '04b2ae03',
'phuix-form-control-view' => '16ad6224',
@ -1407,12 +1407,6 @@ return array(
'javelin-magical-init',
'javelin-util',
),
'623a766b' => array(
'javelin-install',
'javelin-dom',
'phuix-icon-view',
'phabricator-prefab',
),
'628f59de' => array(
'phui-oi-list-view-css',
),
@ -1563,6 +1557,12 @@ return array(
'7f243deb' => array(
'javelin-install',
),
'7fa5c915' => array(
'javelin-install',
'javelin-dom',
'phuix-icon-view',
'phabricator-prefab',
),
'81144dfa' => array(
'javelin-behavior',
'javelin-behavior-device',

View file

@ -521,6 +521,18 @@ JX.install('PHUIXAutocomplete', {
return;
}
// Deactivate immediately if a user types a character that we are
// reasonably sure means they don't want to use the autocomplete. For
// example, "##" is almost certainly a header or monospaced text, not
// a project autocompletion.
var cancels = this._getCancelCharacters();
for (var ii = 0; ii < cancels.length; ii++) {
if (text.indexOf(cancels[ii]) !== -1) {
this._deactivate();
return;
}
}
var trim = this._trim(text);
// If this rule has a prefix pattern, like the "[[ document ]]" rule,
@ -541,18 +553,6 @@ JX.install('PHUIXAutocomplete', {
// This needs to match what we pass to the typeahead datasource.
this._value = trim;
// Deactivate immediately if a user types a character that we are
// reasonably sure means they don't want to use the autocomplete. For
// example, "##" is almost certainly a header or monospaced text, not
// a project autocompletion.
var cancels = this._getCancelCharacters();
for (var ii = 0; ii < cancels.length; ii++) {
if (trim.indexOf(cancels[ii]) !== -1) {
this._deactivate();
return;
}
}
// Deactivate immediately if the user types an ignored token like ":)",
// the smiley face emoticon. Note that we test against "text", not
// "trim", because the ignore list and suffix list can otherwise