Bartosz Dziewoński has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/342664 )
Change subject: ve.ui.LinkAction: Allow autolinking ranges including trailing
spaces again
......................................................................
ve.ui.LinkAction: Allow autolinking ranges including trailing spaces again
VE-MW magic link sequences, which still match trailing spaces, would
no longer work correctly (which was caught by the unit tests).
Follow-up to 32759ae861bb92783315ff89a41d9cdfe4ce4f34.
Change-Id: Ia5d51fea142e6e9df4028c51221c77a87d8caebe
---
M src/ui/actions/ve.ui.LinkAction.js
1 file changed, 9 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/64/342664/1
diff --git a/src/ui/actions/ve.ui.LinkAction.js
b/src/ui/actions/ve.ui.LinkAction.js
index e69608e..c8be7d9 100644
--- a/src/ui/actions/ve.ui.LinkAction.js
+++ b/src/ui/actions/ve.ui.LinkAction.js
@@ -102,15 +102,6 @@
range = selection.getRange();
rangeEnd = range.end;
- // If there's text immediately past the range, don't autolink.
- // The user did something silly like type a link in the middle of a
word.
- if (
- rangeEnd + 1 < documentModel.data.getLength() &&
- /\w/.test( documentModel.data.getText( true, new ve.Range(
rangeEnd, rangeEnd + 1 ) ) )
- ) {
- return false;
- }
-
linktext = documentModel.data.getText( true, range );
// Eliminate trailing whitespace.
@@ -128,6 +119,15 @@
// Shrink range to match new linktext.
range = range.truncate( linktext.length );
+ // If there are word characters (but not punctuation) immediately past
the range, don't autolink.
+ // The user did something silly like type a link in the middle of a
word.
+ if (
+ range.end + 1 < documentModel.data.getLength() &&
+ /\w/.test( documentModel.data.getText( true, new ve.Range(
range.end, range.end + 1 ) ) )
+ ) {
+ return false;
+ }
+
// Check that none of the range has an existing link annotation.
// Otherwise we could autolink an internal link, which would be ungood.
for ( i = range.start; i < range.end; i++ ) {
--
To view, visit https://gerrit.wikimedia.org/r/342664
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5d51fea142e6e9df4028c51221c77a87d8caebe
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits