mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Fix an issue where any diff which could possibly be rendered as Jupyter decided to render as Jupyter
Summary: See PHI1468. Engine selection for diffs is currently too aggressive in trying to find a shared engine and will fall back a shared engine with a very low score, causing all ".json" files to render as Jupyter files. Only pick an engine as a difference engine by default if it's the highest-scoring engine for the new file. Test Plan: Viewed ".json" files and ".ipynb" files in a revision. Before, both rendered as Jupyter. Now, the former rendered as JSON and the latter rendered as Jupyter. Differential Revision: https://secure.phabricator.com/D20850
This commit is contained in:
parent
76d9912932
commit
9f7aaa8ee4
1 changed files with 13 additions and 2 deletions
|
@ -1718,7 +1718,8 @@ final class DifferentialChangesetParser extends Phobject {
|
|||
$viewer,
|
||||
$new_ref);
|
||||
|
||||
$shared_engines = array_intersect_key($old_engines, $new_engines);
|
||||
$shared_engines = array_intersect_key($new_engines, $old_engines);
|
||||
$default_engine = head_key($new_engines);
|
||||
|
||||
foreach ($shared_engines as $key => $shared_engine) {
|
||||
if (!$shared_engine->canDiffDocuments($old_ref, $new_ref)) {
|
||||
|
@ -1734,7 +1735,17 @@ final class DifferentialChangesetParser extends Phobject {
|
|||
$document_engine = null;
|
||||
}
|
||||
} else {
|
||||
$document_engine = head($shared_engines);
|
||||
// If we aren't rendering with a specific engine, only use a default
|
||||
// engine if the best engine for the new file is a shared engine which
|
||||
// can diff files. If we're less picky (for example, by accepting any
|
||||
// shared engine) we can end up with silly behavior (like ".json" files
|
||||
// rendering as Jupyter documents).
|
||||
|
||||
if (isset($shared_engines[$default_engine])) {
|
||||
$document_engine = $shared_engines[$default_engine];
|
||||
} else {
|
||||
$document_engine = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($document_engine) {
|
||||
|
|
Loading…
Reference in a new issue