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.
This commit is contained in:
Jonathan Clem
2020-03-10 12:42:42 -04:00
parent c0539b197b
commit 6fa6718a88
+1 -1
View File
@@ -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' }}]