Don't try to avoid username completion appearing in email addresses

Current code breaks in other languages which don't use whitespace as a
word separator. The word-separator message is (for reasons) not reliably
set to something other than " " on wikis for those languages, so we
can't use it as a trigger for just not caring.

Bug: T255153
Change-Id: I1ff929811af59fd7a7bf7e8dfc1cd121a2c4db4e
This commit is contained in:
David Lynch 2020-06-11 11:57:28 -05:00 committed by Ed Sanders
parent 303b233ca1
commit d7557d5ab3

View file

@ -47,25 +47,6 @@ MWUsernameCompletionAction.static.methods.push( 'insertAndOpen' );
/* Methods */
MWUsernameCompletionAction.prototype.open = function () {
var surfaceModel = this.surface.getModel(),
data = surfaceModel.getDocument().data,
offset = surfaceModel.getSelection().getRange(),
// The character before the @:
precedingCharacterOffset = new ve.Range(
offset.from - MWUsernameCompletionAction.static.triggerLength - 1,
offset.from - MWUsernameCompletionAction.static.triggerLength
),
precedingCharacter = data.getText( false, precedingCharacterOffset );
// This is fundamentally "don't trigger on email addresses"
if ( precedingCharacter && !precedingCharacter.match( /\s/ ) ) {
return false;
}
return MWUsernameCompletionAction.super.prototype.open.apply( this, arguments );
};
MWUsernameCompletionAction.prototype.insertAndOpen = function () {
this.surface.getModel().getFragment().insertContent( '@' ).collapseToEnd().select();
// Skip precedingCharacter check in #open as we know the user intention