Page MenuHomePhabricator

Does not find "\n" though existing on page when searching for regular expression in VisualEditor
Closed, ResolvedPublic8 Estimated Story Points

Description

The research of regular expression like the character "\n" does not give any result on a page even if the page contains such characters and the option regular expression is checked.

To reproduce:

  1. Go to https://en.wikipedia.org/w/index.php?title=Newline&action=edit
  1. Switch to visual mode
  1. Type Ctrl + F.
  1. Check the option Regular expression and search for "\n"

This has been check on English Wikipedia and French Wikisource with Firefox browser under Ubuntu.

Event Timeline

Aklapper renamed this task from Search on regular expression not functional. to Does not find "\n" though existing on page when searching for regular expression in VisualEditor.Mar 1 2018, 6:29 PM
Elitre renamed this task from Does not find "\n" though existing on page when searching for regular expression in VisualEditor to Search on regular expression not functional..Mar 1 2018, 6:29 PM
Elitre added a project: VisualEditor.
Elitre added a subscriber: Deskana.
Aklapper renamed this task from Search on regular expression not functional. to Does not find "\n" though existing on page when searching for regular expression in VisualEditor.Mar 1 2018, 6:29 PM

Sorry Andre, I think I edit conflicted you.

Just to confirm, this is your input, right?

image.png (503×1 px, 123 KB)

Can you clarify what behavior you expect?

\n in regexp mode will search for a literal newline character, and I don't think there are any on this page. Do you expect it to match the paragraph breaks? Or <br /> elements? Or the literal "\n" (backslash followed by 'n') that appears a few times on the page?

Yes this is my input.
Indeed I expect it to match the newline character. The page which trigger the bug discovery was:
https://fr.wikisource.org/wiki/Page:Darwin_-_Voyage_d%E2%80%99un_naturaliste_autour_du_monde,_trad._Barbier,_1875.djvu/516

Where there are many of them and I was trying to remove them.

matmarex triaged this task as Low priority.
matmarex edited projects, added VisualEditor (Current work); removed VisualEditor.

The reason for this is because we use "\n" internally as a "replacement character" for anything that is not text when performing the searches, and so it's ignored in the results. We can probably change this. I'm picking it up even though it's "Low" because I just ran into another bug report that would also be solved by this (T184163).

I think this is a simpler special case of T151671. This task is just about literal newline characters when editing visually (displayed on VE surface as "↵"). That one is about line breaks when editing source in NWE, which is actually a lot more difficult because we pretend they are paragraph end/start nodes.

Change 427022 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[VisualEditor/VisualEditor@master] Improve behavior of newlines and non-text content elements in find-and-replace

https://gerrit.wikimedia.org/r/427022

Change 427022 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] Improve behavior of newlines and non-text content elements in find-and-replace

https://gerrit.wikimedia.org/r/427022

Change 432608 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (b8c05e38c)

https://gerrit.wikimedia.org/r/432608

Change 432608 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (b8c05e38c)

https://gerrit.wikimedia.org/r/432608