Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #1678, undo no longer clears cells #1965

Merged
merged 1 commit into from
Jun 15, 2012
Merged

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Jun 15, 2012

With these changes, Ctrl-Z inside of codemirror cells will only undo up to the text that was in the cell when it was loaded from JSON. This fixes #1678.

I found another bug where switching the cell type causes the loss of all
undo history for that cell. With this commit, switching the cell type
simply resets the history to whatever it was at the time of the cell type switch.

For example, if a cell had contents changed from X -> Y -> Z, and then you change the cell type, before this commit, its history becomes Ø -> Z (where Ø is just empty), so pressing Ctrl-Z once in a changed cell just erases all of it's contents. After this commit, the new cell's history just gets reset to Z

I found another bug where switching the cell type causes the loss of all
undo history for that cell. With this commit, switching the cell type
simply resets the history
@minrk
Copy link
Member

minrk commented Jun 15, 2012

What's the difference between losing and resetting the history?

@ivanov
Copy link
Member Author

ivanov commented Jun 15, 2012

In the notebook, when a CodeMirror cell is initiated, it's text value is set to a blank. Later, the cell value gets set with set_text(text) - which causes that to be an entry in the cell's history, and so the undo history's initial entry is that of a blank value. So resetting the history after a call to set_text causes the initial entry to become whatever it was in the JSON.

@minrk
Copy link
Member

minrk commented Jun 15, 2012

ok, thanks.

@ivanov
Copy link
Member Author

ivanov commented Jun 15, 2012

sorry about the confusing wording, if a cell had contents changed from X -> Y -> Z, and then you change the cell type, before this commit, its history becomes Ø -> Z (where Ø is just empty), so pressing Ctrl-Z once in a changed cell just erases all of it's contents. After this commit, the new cell's history just gets reset to Z

@minrk
Copy link
Member

minrk commented Jun 15, 2012

Is there any case where calling 'set_text' shouldn't do this? I'm wondering if that's where this call belongs.

@minrk
Copy link
Member

minrk commented Jun 15, 2012

If that's not true, then I'm fine merging as-is, and we can worry about consolidation later.

@ivanov
Copy link
Member Author

ivanov commented Jun 15, 2012

Is there any case where calling 'set_text' shouldn't do this?

yes. Merging or splitting a cell also uses set_text. So if you do a split, and then change your mind, you can actually undo back within both cells and one of them will return to the unified pre-split stage, and the other will return to empty state.

%load and %loadpy magics also ends up using set_text - and since those create new cells, and all new cells created within a session have Ø at the root of their history, not resetting the history keeps things consistent.

I can also imagine downstream widgets using this function, the effects of which would then be undo-able

@minrk
Copy link
Member

minrk commented Jun 15, 2012

gotcha, merging as-is then.

minrk added a commit that referenced this pull request Jun 15, 2012
fix for #1678, undo no longer clears cells

With these changes, Ctrl-Z inside of codemirror cells will only undo up to the text that was in the cell when it was loaded from JSON.

closes #1678
@minrk minrk merged commit 172b680 into ipython:master Jun 15, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
fix for ipython#1678, undo no longer clears cells

With these changes, Ctrl-Z inside of codemirror cells will only undo up to the text that was in the cell when it was loaded from JSON.

closes ipython#1678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ctrl-z clears cell output in notebook when pressed enough times
2 participants