mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) simplify document comparison code, and flesh out diff with local changes
Summary: With recent changes to action history, we can now remove the temporary `finalRowContent` field from change details, since all the information we need is now in the ActionSummary. We also now have more information about the state of the common ancestor, which previously we could not get either from ActionSummary or from `finalRowContent`. We take advantage of that to flesh out rendering differences where there are some changes locally and some changes remotely. There's still a lot more to do, this is just one step. I have added a link to the UI for viewing the comparison. I wouldn't want to advertise that link until diffs are robust to name changes. Test Plan: added test, updated tests Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2658
This commit is contained in:
@@ -74,23 +74,25 @@ export class DiffBox extends NewAbstractWidget {
|
||||
// selected on the basis of one column, but we are displaying the
|
||||
// content of another. We have more version information for the
|
||||
// reference column than for its display column.
|
||||
return [[DIFF_EQUAL, formatter.format(value)]];
|
||||
return [[DIFF_EQUAL, formatter.formatAny(value)]];
|
||||
}
|
||||
const versions = value[1];
|
||||
if (!('local' in versions)) {
|
||||
// Change was made remotely only.
|
||||
return this._prepareTextDiff(formatter.format(versions.parent),
|
||||
formatter.format(versions.remote));
|
||||
return this._prepareTextDiff(
|
||||
formatter.formatAny(versions.parent),
|
||||
formatter.formatAny(versions.remote));
|
||||
} else if (!('remote' in versions)) {
|
||||
// Change was made locally only.
|
||||
return this._prepareTextDiff(formatter.format(versions.parent),
|
||||
formatter.format(versions.local))
|
||||
return this._prepareTextDiff(
|
||||
formatter.formatAny(versions.parent),
|
||||
formatter.formatAny(versions.local))
|
||||
.map(([code, txt]) => [code === DIFF_INSERT ? DIFF_LOCAL : code, txt]);
|
||||
}
|
||||
// Change was made both locally and remotely.
|
||||
return [[DIFF_DELETE, formatter.format(versions.parent)],
|
||||
[DIFF_LOCAL, formatter.format(versions.local)],
|
||||
[DIFF_INSERT, formatter.format(versions.remote)]];
|
||||
return [[DIFF_DELETE, formatter.formatAny(versions.parent)],
|
||||
[DIFF_LOCAL, formatter.formatAny(versions.local)],
|
||||
[DIFF_INSERT, formatter.formatAny(versions.remote)]];
|
||||
}
|
||||
|
||||
// Run diff-match-patch on the text, do its cleanup, and then some extra
|
||||
|
||||
Reference in New Issue
Block a user