Page MenuHomePhabricator

VisualEditor and 2017 wikitext editor: Find & Replace fails to replace when using positive lookaheads/lookbehinds
Open, Needs TriagePublicBUG REPORT

Description

Tested in Chrome and Firefox. It does not occur with negative lookaheads/lookbehinds.

Steps to Reproduce:

  1. Edit any wiki page in any of these two editors.
  2. Press Ctrl+F to open Find & Replace.
  3. Enable regex by clicking the "(.*)" button.
  4. Type a query followed by a positive lookahead or lookbehind, i.e. "test(?=ing)" or "(?<=test)ing". Make sure it has matches on the page.
  5. Click "Replace".

Actual Results:

The matched text is not replaced, and the find & replace tool skips to the next match.

Expected Results:

The matched text is replaced.

Event Timeline

SUM1 renamed this task from VisualEditor and 2017 wikitext editor: Find & Replace fails to replace when using positive lookaheads to VisualEditor and 2017 wikitext editor: Find & Replace fails to replace when using positive lookaheads/lookbehinds.Apr 27 2020, 7:47 AM
SUM1 updated the task description. (Show Details)

They don't work correctly because the editor does the replacement only on the already matched substring, rather than the entire document string: https://gerrit.wikimedia.org/g/VisualEditor/VisualEditor/+/1a98e553b34811d50a14b2dc61c34e7460e60163/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js#603