1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

When autocompleting, add a space if a user didn't already add something

Summary: Ref T10163. When a user autocompletes, add a space for them, unless they already added a comma, colon, or space themsevles.

Test Plan: Autocompleted `@dog`, got `@dog `. Autocompleted `@epriestley,` got `@epriestley,`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10163

Differential Revision: https://secure.phabricator.com/D15041
This commit is contained in:
epriestley 2016-01-16 15:06:15 -08:00
parent 75781dba1a
commit b7fe07bbd6
2 changed files with 16 additions and 9 deletions

View file

@ -507,7 +507,7 @@ return array(
'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836',
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
'rsrc/js/phuix/PHUIXActionView.js' => '8cf6d262',
'rsrc/js/phuix/PHUIXAutocomplete.js' => '8bbbad27',
'rsrc/js/phuix/PHUIXAutocomplete.js' => 'fc10c813',
'rsrc/js/phuix/PHUIXDropdownMenu.js' => 'bd4c8dca',
'rsrc/js/phuix/PHUIXFormControl.js' => '8fba1997',
'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b',
@ -836,7 +836,7 @@ return array(
'phui-workpanel-view-css' => 'adec7699',
'phuix-action-list-view' => 'b5c256b8',
'phuix-action-view' => '8cf6d262',
'phuix-autocomplete' => '8bbbad27',
'phuix-autocomplete' => 'fc10c813',
'phuix-dropdown-menu' => 'bd4c8dca',
'phuix-form-control-view' => '8fba1997',
'phuix-icon-view' => 'bff6884b',
@ -1489,12 +1489,6 @@ return array(
'javelin-stratcom',
'javelin-vector',
),
'8bbbad27' => array(
'javelin-install',
'javelin-dom',
'phuix-icon-view',
'phabricator-prefab',
),
'8bdb2835' => array(
'phui-fontkit-css',
),
@ -2092,6 +2086,12 @@ return array(
'javelin-behavior-device',
'phabricator-keyboard-shortcut',
),
'fc10c813' => array(
'javelin-install',
'javelin-dom',
'phuix-icon-view',
'phabricator-prefab',
),
'fc91ab6c' => array(
'javelin-behavior',
'javelin-dom',

View file

@ -600,19 +600,26 @@ JX.install('PHUIXAutocomplete', {
return false;
}
// If the user types a string like "@username:" (with a trailing comma),
// If the user types a string like "@username:" (with a trailing colon),
// then presses tab or return to pick the completion, don't destroy the
// trailing character.
var suffixes = this._getSuffixes();
var value = this._value;
var found_suffix = false;
for (var ii = 0; ii < suffixes.length; ii++) {
var last = value.substring(value.length - suffixes[ii].length);
if (last == suffixes[ii]) {
ref += suffixes[ii];
found_suffix = true;
break;
}
}
// If we didn't find an existing suffix, add a space.
if (!found_suffix) {
ref = ref + ' ';
}
area.value = text.substring(0, head - 1) + ref + text.substring(tail);
var end = head + ref.length;