mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01: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:
parent
75781dba1a
commit
b7fe07bbd6
2 changed files with 16 additions and 9 deletions
|
@ -507,7 +507,7 @@ return array(
|
||||||
'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836',
|
'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836',
|
||||||
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
|
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
|
||||||
'rsrc/js/phuix/PHUIXActionView.js' => '8cf6d262',
|
'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/PHUIXDropdownMenu.js' => 'bd4c8dca',
|
||||||
'rsrc/js/phuix/PHUIXFormControl.js' => '8fba1997',
|
'rsrc/js/phuix/PHUIXFormControl.js' => '8fba1997',
|
||||||
'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b',
|
'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b',
|
||||||
|
@ -836,7 +836,7 @@ return array(
|
||||||
'phui-workpanel-view-css' => 'adec7699',
|
'phui-workpanel-view-css' => 'adec7699',
|
||||||
'phuix-action-list-view' => 'b5c256b8',
|
'phuix-action-list-view' => 'b5c256b8',
|
||||||
'phuix-action-view' => '8cf6d262',
|
'phuix-action-view' => '8cf6d262',
|
||||||
'phuix-autocomplete' => '8bbbad27',
|
'phuix-autocomplete' => 'fc10c813',
|
||||||
'phuix-dropdown-menu' => 'bd4c8dca',
|
'phuix-dropdown-menu' => 'bd4c8dca',
|
||||||
'phuix-form-control-view' => '8fba1997',
|
'phuix-form-control-view' => '8fba1997',
|
||||||
'phuix-icon-view' => 'bff6884b',
|
'phuix-icon-view' => 'bff6884b',
|
||||||
|
@ -1489,12 +1489,6 @@ return array(
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
'javelin-vector',
|
'javelin-vector',
|
||||||
),
|
),
|
||||||
'8bbbad27' => array(
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-dom',
|
|
||||||
'phuix-icon-view',
|
|
||||||
'phabricator-prefab',
|
|
||||||
),
|
|
||||||
'8bdb2835' => array(
|
'8bdb2835' => array(
|
||||||
'phui-fontkit-css',
|
'phui-fontkit-css',
|
||||||
),
|
),
|
||||||
|
@ -2092,6 +2086,12 @@ return array(
|
||||||
'javelin-behavior-device',
|
'javelin-behavior-device',
|
||||||
'phabricator-keyboard-shortcut',
|
'phabricator-keyboard-shortcut',
|
||||||
),
|
),
|
||||||
|
'fc10c813' => array(
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-dom',
|
||||||
|
'phuix-icon-view',
|
||||||
|
'phabricator-prefab',
|
||||||
|
),
|
||||||
'fc91ab6c' => array(
|
'fc91ab6c' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
|
|
@ -600,19 +600,26 @@ JX.install('PHUIXAutocomplete', {
|
||||||
return false;
|
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
|
// then presses tab or return to pick the completion, don't destroy the
|
||||||
// trailing character.
|
// trailing character.
|
||||||
var suffixes = this._getSuffixes();
|
var suffixes = this._getSuffixes();
|
||||||
var value = this._value;
|
var value = this._value;
|
||||||
|
var found_suffix = false;
|
||||||
for (var ii = 0; ii < suffixes.length; ii++) {
|
for (var ii = 0; ii < suffixes.length; ii++) {
|
||||||
var last = value.substring(value.length - suffixes[ii].length);
|
var last = value.substring(value.length - suffixes[ii].length);
|
||||||
if (last == suffixes[ii]) {
|
if (last == suffixes[ii]) {
|
||||||
ref += suffixes[ii];
|
ref += suffixes[ii];
|
||||||
|
found_suffix = true;
|
||||||
break;
|
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);
|
area.value = text.substring(0, head - 1) + ref + text.substring(tail);
|
||||||
|
|
||||||
var end = head + ref.length;
|
var end = head + ref.length;
|
||||||
|
|
Loading…
Reference in a new issue