jenkins-bot has submitted this change and it was merged. Change subject: Show a message when an invalid regex is inputted in F&R ......................................................................
Show a message when an invalid regex is inputted in F&R Change-Id: I5f077ca0ee7442f291e41e53531a092a3c3731d4 --- M i18n/en.json M i18n/qqq.json M src/ui/dialogs/ve.ui.FindAndReplaceDialog.js 3 files changed, 10 insertions(+), 4 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/i18n/en.json b/i18n/en.json index c9235be..a17fedf 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -54,6 +54,7 @@ "visualeditor-dimensionswidget-times": "×", "visualeditor-find-and-replace-done": "Done", "visualeditor-find-and-replace-find-text": "Find", + "visualeditor-find-and-replace-invalid-regex": "Invalid regular expression", "visualeditor-find-and-replace-match-case": "Match case", "visualeditor-find-and-replace-next-button": "Find next", "visualeditor-find-and-replace-previous-button": "Find previous", diff --git a/i18n/qqq.json b/i18n/qqq.json index 53e3498..900064a 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -61,6 +61,7 @@ "visualeditor-dimensionswidget-times": "{{optional}}\nLabel for the dimensions properties denoting 'by', as in width x height.", "visualeditor-find-and-replace-done": "Label for button to finish using the find and replace dialog\n{{Identical|Done}}", "visualeditor-find-and-replace-find-text": "Label for find text in find and replace\n{{Identical|Find}}", + "visualeditor-find-and-replace-invalid-regex": "Inline error message shown for an invalid regular expression", "visualeditor-find-and-replace-match-case": "Label for match case toggle in find and replace", "visualeditor-find-and-replace-next-button": "Label for find next result button in find and replace", "visualeditor-find-and-replace-previous-button": "Label for find previous result button in find and replace", diff --git a/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js b/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js index fd30b54..5609587 100644 --- a/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js +++ b/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js @@ -19,6 +19,7 @@ // Properties this.surface = null; + this.invalidRegex = false; // Pre-initialization this.$element.addClass( 've-ui-findAndReplaceDialog' ); @@ -266,7 +267,6 @@ */ ve.ui.FindAndReplaceDialog.prototype.updateFragments = function () { var i, l, - hasError = false, surfaceModel = this.surface.getModel(), documentModel = surfaceModel.getDocument(), ranges = [], @@ -274,16 +274,18 @@ isRegex = this.regexToggle.getValue(), find = this.findText.getValue(); + this.invalidRegex = false; + if ( isRegex && find ) { try { this.query = new RegExp( find ); } catch ( e ) { - hasError = true; + this.invalidRegex = true; } } else { this.query = find; } - this.findText.$element.toggleClass( 've-ui-findAndReplaceDialog-findText-error', hasError ); + this.findText.$element.toggleClass( 've-ui-findAndReplaceDialog-findText-error', this.invalidRegex ); this.fragments = []; if ( this.query ) { @@ -378,7 +380,9 @@ ve.msg( 'visualeditor-find-and-replace-results', this.focusedIndex + 1, this.results ) ); } else { - this.focusedIndexLabel.setLabel( '' ); + this.focusedIndexLabel.setLabel( + this.invalidRegex ? ve.msg( 'visualeditor-find-and-replace-invalid-regex' ) : '' + ); return; } -- To view, visit https://gerrit.wikimedia.org/r/187442 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5f077ca0ee7442f291e41e53531a092a3c3731d4 Gerrit-PatchSet: 2 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits