Page MenuHomePhabricator

Correct a prose diff behavior when prose pieces include newlines
ClosedPublic

Authored by epriestley on May 30 2020, 9:04 PM.

Details

Summary

See https://discourse.phabricator-community.org/t/bad-regex-in-prose-diff-logic/3969.

The prose splitting rules normally guarantee that newlines appear only at the beginning or end of blocks. However, if a prose sentence ends with text like "...x\n.", we can end up with a newline inside a "sentence".

If we do, the regular expression that breaks it into pieces will fail.

Arguably, this is an error in how sentences are split apart (we might prefer to split this into two sentences, "x\n" and ".", rather than a single "x\n." sentence) but in the general case it's not unreasonable for blocks to contain newlines, so a simple fix is to make the pattern more robust.

Test Plan

Added a failing test which includes this behavior, made it pass.

Diff Detail

Repository
rP Phabricator
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

epriestley created this revision.May 30 2020, 9:04 PM
epriestley requested review of this revision.May 30 2020, 9:05 PM
This revision was not accepted when it landed; it landed in state Needs Review.May 30 2020, 9:11 PM
This revision was automatically updated to reflect the committed changes.

thanks. I can confirm the change lets the daemon finish the task and renders a reasonable diff.