Skip to content

Commit

Permalink
fix bug where decorations were not being cleared properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jharris4 committed Jan 19, 2023
1 parent 05bcaef commit b5add94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-plants-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j-cypher/codemirror": patch
---

fix bug where decorations were not being cleared properly
5 changes: 3 additions & 2 deletions packages/codemirror/src/cypher-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ const typeMarkerFromTo = (view, options = {}) => {
};

export const resetColors = (view, editorSupport) => {
view.dispatch(clearTypeMarkersEffect.of());
const effects = [clearTypeMarkersEffect.of()];
view.dispatch({ effects });
};

export const fixColors = (view, editorSupport) => {
view.dispatch(clearTypeMarkersEffect.of());
resetColors(view, editorSupport);
if (editorSupport.parseTree == null) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/codemirror/src/cypher-state-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const typeMarkerField = StateField.define({
typeMarkers = typeMarkers.map(tr.changes);
for (let e of tr.effects) {
if (e.is(clearTypeMarkersEffect)) {
typeMarkers = typeMarkers.filter(() => false);
typeMarkers = Decoration.none;
} else if (e.is(addTypeMarkerEffect)) {
if (e.value.from !== e.value.to) {
typeMarkers = typeMarkers.update({
Expand Down

0 comments on commit b5add94

Please sign in to comment.