Page MenuHomePhabricator

Extract scope line selection logic from the diff rendering engine so it can reasonably be iterated on

Authored by epriestley on Feb 14 2019, 6:11 PM.



Ref T13249. Ref T11738. See PHI985. Currently, we have a crude heuristic for guessing what line in a source file provides the best context.

We get it wrong in a lot of cases, sometimes selecting very silly lines like "{". Although we can't always pick the same line a human would pick, we can pile on heuristics until this is less frequently completely wrong and perhaps eventually get it to work fairly well most of the time.

Pull the logic for this into a separate standalone class and make it testable to prepare for adding heuristics.

Test Plan

Ran unit tests, browsed various files in the web UI and saw as-good-or-better context selection.

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Feb 19 2019, 6:19 PM

This and two other followups also all have some flavor of "convert tabs to spaces" or vice versa. I suspect we can have fewer copies of this code eventually, but since it's like 10 lines of code I'm not worrying about it too much for now.

This revision was automatically updated to reflect the committed changes.