From 34c3ea472d9b45d472b1fdc6d3d0496a99c7c7d0 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 13 Aug 2021 15:56:08 -0400 Subject: [PATCH] Credit user with a fix if they touched any involved entity This can occur if there are several ways disconnected from the graph and the user fixes these, but then partially undoes their fixes. The current diff might not contain the entity that fixed the issue (reconnected the disconnected graph), but they did fix the issue elsewhere. --- modules/core/validator.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/core/validator.js b/modules/core/validator.js index 12e739e95..0f8a3a1c8 100644 --- a/modules/core/validator.js +++ b/modules/core/validator.js @@ -622,10 +622,11 @@ export function coreValidator(context) { // `updateResolvedIssues()` (private) // Determine if any issues were resolved for the given entities. // This is called by `validate()` after validation of the head graph + // // Give the user credit for fixing an issue if: // - the issue is in the base cache // - the issue is not in the head cache - // - the user did something to that entity + // - the user did something to one of the entities involved in the issue // // Arguments // `entityIDs` - Array containing entity IDs. @@ -635,9 +636,13 @@ export function coreValidator(context) { const baseIssues = _baseCache.issuesByEntityID[entityID]; if (!baseIssues) return; - const userModified = _completeDiff.hasOwnProperty(entityID); baseIssues.forEach(issueID => { - if (userModified && !_headCache.issuesByIssueID[issueID]) { + // Check if the user did something to one of the entities involved in this issue. + // (This issue could involve multiple entities, e.g. disconnected routable features) + const issue = _baseCache.issuesByIssueID[issueID]; + const userModified = (issue.entityIds || []).some(id => _completeDiff.hasOwnProperty(id)); + + if (userModified && !_headCache.issuesByIssueID[issueID]) { // issue seems fixed _resolvedIssueIDs.add(issueID); } else { // issue still not resolved _resolvedIssueIDs.delete(issueID); // (did undo, or possibly fixed and then re-caused the issue)