From 3e6c28f15a24b20976593621e8fd41b97fbfec58 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 24 Nov 2022 21:56:20 +0530 Subject: [PATCH] fix #1103 --- cypress/e2e/diagramUpdate.spec.ts | 8 ++++++++ cypress/snapshots.js | 2 +- src/lib/util/state.ts | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/diagramUpdate.spec.ts b/cypress/e2e/diagramUpdate.spec.ts index 07bd430a..317a62a1 100644 --- a/cypress/e2e/diagramUpdate.spec.ts +++ b/cypress/e2e/diagramUpdate.spec.ts @@ -69,6 +69,14 @@ describe('Auto sync tests', () => { ) .should('exist'); }); + + it.only('should update diagram after entire text is removed', () => { + // https://github.com/mermaid-js/mermaid-live-editor/issues/1102 + getEditor().type(`${cmd} a {backspace}`); + getEditor().type('graph LR'); + getEditor().type(' {enter} A-->Car'); + cy.get('#view').contains('Car').should('exist'); + }); }); describe('Pan and Zoom', () => { diff --git a/cypress/snapshots.js b/cypress/snapshots.js index a66a23cb..547d2f44 100644 --- a/cypress/snapshots.js +++ b/cypress/snapshots.js @@ -16,7 +16,7 @@ module.exports = { "1": "{\"code\":\"graph TD\\n A[Party] -->|Get money| B(Go shopping!!)\\n \",\"mermaid\":\"{\\n \\\"theme\\\": \\\"forest\\\",\\n \\\"test\\\": \\\"hello world\\\"\\n}\",\"autoSync\":true,\"updateDiagram\":true,\"loader\":{\"type\":\"files\",\"config\":{\"codeURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/code.mmd\",\"configURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/config.json\"}}}" } }, - "__version": "10.10.0", + "__version": "11.2.0", "Auto sync tests": { "should dim diagram when code is edited": { "1": "{\"code\":\"graph TD\\n A[Christmas] -->|Get money| B(Go shopping)\\n B --> C{Let me think}\\n C -->|One| D[Laptop]\\n C -->|Two| E[iPhone]\\n C -->|Three| F[fa:fa-car Car]\\n C --> Test\",\"mermaid\":\"{\\n \\\"theme\\\": \\\"default\\\"\\n}\",\"autoSync\":false,\"updateDiagram\":false}" diff --git a/src/lib/util/state.ts b/src/lib/util/state.ts index c8a2619e..6181096a 100644 --- a/src/lib/util/state.ts +++ b/src/lib/util/state.ts @@ -70,11 +70,11 @@ const processState = async (state: State) => { errorDebug(); console.error(e); if ('hash' in e) { - const { - loc: { first_line, last_line, first_column, last_column } - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - } = e.hash as ErrorHash; try { + const { + loc: { first_line, last_line, first_column, last_column } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + } = e.hash as ErrorHash; const marker: MarkerData = { severity: 8, // Error startLineNumber: first_line,