From 6fa6718a8840ca1c4d61b2d547bea5cc05a92d07 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Tue, 10 Mar 2020 12:42:42 -0400 Subject: [PATCH] Use `replace` instead of `push` on code change Using `push` pollutes the browser history, adding a new entry on every keystroke in the editor. This commit replaces it with `replace`, ensuring that the editor gets a single history entry, but that the URL is still updated as code changes. --- src/components/Editor.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Editor.svelte b/src/components/Editor.svelte index 405a655d..d1b02957 100644 --- a/src/components/Editor.svelte +++ b/src/components/Editor.svelte @@ -36,7 +36,7 @@ const handleCodeUpdate = code => { codeErrorStore.set(e); console.log('Error in parsed', e.hash); const str = JSON.stringify({ code: code, mermaid: conf }); - push('/edit/' + Base64.encodeURI(str)) + replace('/edit/' + Base64.encodeURI(str)) const l = e.hash.line; decArr.push(edit.deltaDecorations([], [ { range: new monaco.Range(e.hash.loc.first_line,e.hash.loc.last_line,e.hash.loc.first_column,e.hash.loc.last_column), options: { inlineClassName: 'myInlineDecoration' }}]