Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Multiple tabs share undo buffer #3

Closed
Conduitry opened this issue Apr 19, 2019 · 4 comments · Fixed by #102
Closed

Multiple tabs share undo buffer #3

Conduitry opened this issue Apr 19, 2019 · 4 comments · Fixed by #102
Labels
bug Something isn't working

Comments

@Conduitry
Copy link
Member

There seems to be one common undo/redo buffer shared between all tabs of the REPL. To make matters worse, switching between tabs is something that the editor apparently sees as an update to the text in it - so if you switch from tab A to tab B and then press ctrl-z/cmd-z/whatever, you will end up with the contents of tab A in tab B.

@Conduitry
Copy link
Member Author

The document object in CodeMirror does provide doc.getHistory(), doc.setHistory(), and doc.clearHistory() methods which will be useful here. When we switch away from a tab, we should call getHistory and save the history somewhere specific to the tab. When we switch to a tab, we should check whether we'd previously saved any history for it and call setHistory or clearHistory as appropriate.

@Conduitry Conduitry added the bug Something isn't working label May 13, 2019
@weepy
Copy link

weepy commented Oct 16, 2019

ah yes i got bitten by this +1

@Danny-Engelman
Copy link

I was bitten many times by this.

Tried a quick test with the above mentioned get/setHistory from the console,
but that doesn't seem to work

The issue seems to be the editor content is not the same

The CodeMirror docs says:

image

@mustafa0x
Copy link

The simplest solution would probably be to initiate a CodeMirror instance for each tab. More expensive, but worth it I feel, since all state is preserved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants