Skip to content

Commit

Permalink
Show conflicts even when paused.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Sep 18, 2024
1 parent 2f55110 commit 9b19d43
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http:

## 0.11.2 2024-09-17

### Added

- Show conflicts even when paused.

### Maintenance

- Several dependendabot pull request updates.
Expand Down
108 changes: 53 additions & 55 deletions src/components/annotations/Annotations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,65 @@
// Wait for DOM updates so that everything is in position before we layout annotations.
await tick();
annotations = [];
// Reset the annotation list to active annotations.
annotations = conflicts
.map((conflict: Conflict) => {
const nodes = conflict.getConflictingNodes(context, Templates);
const primary = nodes.primary;
const secondary = nodes.secondary;
// Based on the primary and secondary nodes given, decide what to show.
// We expect
// 1) a single primary node
// 2) zero or more secondary nodes
// From these, we generate one or two speech bubbles to illustrate the conflict.
return [
{
node: primary.node,
element: getNodeView(primary.node),
messages: [
primary.explanation(
$locales,
project.getNodeContext(primary.node) ??
project.getContext(project.getMain()),
),
],
kind: conflict.isMinor()
? ('minor' as const)
: ('primary' as const),
context,
// Place the resolutions in the primary node.
resolutions: nodes.resolutions,
},
...(secondary !== undefined
? [
{
node: secondary.node,
element: getNodeView(secondary.node),
messages: [
secondary.explanation(
$locales,
project.getNodeContext(
secondary.node,
),
),
],
context,
kind: 'secondary' as const,
},
]
: []),
];
})
.flat();
// If stepping, add the current evaluation.
if (stepping) {
const [node, view] = getStepView();
// Return a single annotation for the step.
if (node && source.contains(node))
annotations = [
...annotations,
{
node: node,
element: view,
Expand All @@ -125,60 +177,6 @@
context,
},
];
} else {
// Conflict all of the active conflicts to a list of annotations.
annotations = conflicts
.map((conflict: Conflict) => {
const nodes = conflict.getConflictingNodes(
context,
Templates,
);
const primary = nodes.primary;
const secondary = nodes.secondary;
// Based on the primary and secondary nodes given, decide what to show.
// We expect
// 1) a single primary node
// 2) zero or more secondary nodes
// From these, we generate one or two speech bubbles to illustrate the conflict.
return [
{
node: primary.node,
element: getNodeView(primary.node),
messages: [
primary.explanation(
$locales,
project.getNodeContext(primary.node) ??
project.getContext(project.getMain()),
),
],
kind: conflict.isMinor()
? ('minor' as const)
: ('primary' as const),
context,
// Place the resolutions in the primary node.
resolutions: nodes.resolutions,
},
...(secondary !== undefined
? [
{
node: secondary.node,
element: getNodeView(secondary.node),
messages: [
secondary.explanation(
$locales,
project.getNodeContext(
secondary.node,
),
),
],
context,
kind: 'secondary' as const,
},
]
: []),
];
})
.flat();
}
// Now organize by node.
Expand Down

0 comments on commit 9b19d43

Please sign in to comment.