mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
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:
parent
303b233ca1
commit
d7557d5ab3
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue