Page MenuHomePhabricator

External text with CRLF line endings breaks text processing in NWE
Closed, ResolvedPublic

Description

Pasting in text with CRLF line endings appears to break the new VE-based wikitext editor.

Steps:

  1. Use Chrome or Edge (not Firefox)
  2. Log in and enable "new wikitext mode"
  3. Begin editing a page
  4. Paste in some text with CRLF line endings
  5. Try to continue editing the text (particularly after the pasted text)
    • See that cursor is no longer positioned correctly, undo no longer works correctly, etc
  6. Copy all the text at that point and paste it into another (functioning) text editor
    • See that the text being produced also no longer matches the text being displayed

Before:


After pasting 4 lines of text with their CRLF endings, then attempting to type ^^^^ at the end of line 6:

After pasting 4 lines of text with their CRLF endings, then pressing "undo" once:

Desired behavior: not that. (text insertion at cursor position, undo reversing the operation correctly, etc)

Notes:

  • First noticed this issue about a month ago
  • Doesn't occur when pasting in text with LF-only line endings (workaround)
  • Doesn't occur in Firefox (may be stripping the CRs when pasting text)
  • This issue and NWE in general are essentially identical in Chrome and Edge
  • Windows 10 was not at all happy while testing this for whatever reason

Apologies if this is in the wrong place or wrong format, first time submitting anything through the WM phab.

Event Timeline

Restricted Application added a project: VisualEditor. · View Herald TranscriptSep 26 2018, 6:06 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Thank you, excellent bug report :) I can reproduce the problem.

Most of the issues disappear when I disable syntax highlighting in the editor. Without syntax highlighting, the only problem is invisible CR characters appearing at the end of the pasted lines, which is awkward, but they don't break the editor.

(I think the syntax highlighting overlay handles CRLF newlines "correctly", causing the cursor offsets in the overlay and in the real editing surface to not match, which causes the rest of the problems.)

Since this started happening recently, it might be a bug in the new SourceConverter (rGVEDa273ba69c7d7: [BREAKING CHANGE] Implement a SourceConverter).

As a side note, CR newlines cause even more hilarious issues.

Change 463261 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[VisualEditor/VisualEditor@master] ve.dm.SourceConverter: Handle CRLF and CR newlines

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

matmarex claimed this task.Sep 27 2018, 1:43 PM
matmarex edited projects, added VisualEditor (Current work); removed VisualEditor.
matmarex moved this task from Incoming to Code review on the VisualEditor (Current work) board.

Change 463261 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] ve.dm.SourceConverter: Handle CRLF and CR newlines

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

Change 463765 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (e9becf4d0)

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

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

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

Ryasmeen renamed this task from External text with CRLF line endings breaks text processing in NWE to .Nov 14 2018, 1:11 AM
Ryasmeen created this task.Nov 14 2018, 1:16 AM
matmarex moved this task from Inbox to Low Priority on the Editing QA board.Nov 14 2018, 4:30 PM
ppelberg closed this task as Resolved.Apr 16 2019, 6:58 PM