You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Undo of actions taken by package results in corrupted display of buffer #7516
Open a file with some text in it (I used my init.coffee)
Move to a random location
Mark the start of a block using Ctrl+K B
Move someplace later on the line
Mark the end of a block using Ctrl+K K
Move to the next line
Move the block using Ctrl+K M
Undo the action using Cmd+Z
Expected: State of the file to return to where it was before the move Actual: The state of the file itself returns to where it was, but the displayed text includes an extra copy of the line to where the block was moved
@maxbrunsfeld is there anything in particular that is wrong with the code being used in the package?
I'm not sure if this is the same error, but I've been getting similar weird behavior when using undo/redo in vim-mode. It seems to scatter lines all over the place, breaking them into seemingly random places. I can't get the correct state back afterwards. I'm not sure how to reproduce it consistently though.
When a Range object is passed to TextEditor::setTextInRange, that range object is stored in the text-editor's history.
This package atom-joereusesRange objects, mutating their start and end points.
The result is that the text-editor's history gets modified into an inconsistent state. I think that rewriting the blockMove method as follows fixes the problem:
By the way @iarna thanks for this very detailed report; I'm sorry that you had to deal with this confusing behavior. Please let me know if you're still working on atom-joe and notice any other problems with the Atom API.
@maxbrunsfeld I do think we should freeze ranges and points as much as possible. I'm a bit concerned about the implications of doing it universally, since some packages mutate them for convenience. Starting with freezing stuff that goes into the history seems reasonable, and maybe exploring a way to freeze by default is also a good idea.
\o/ Awesome, glad to see this fixed! I'm sure I will continue to do even weirder things w/ my little module, so w/ luck I'll help find some more of the hard to find corner cases. =)
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
iarna commentedon Jun 28, 2015
Example of what I see ↑
lee-dohm commentedon Jun 28, 2015
Repro Steps
joe-keybindspackageinit.coffee)Expected: State of the file to return to where it was before the move
Actual: The state of the file itself returns to where it was, but the displayed text includes an extra copy of the line to where the block was moved
@maxbrunsfeld is there anything in particular that is wrong with the code being used in the package?
azoerb commentedon Jul 2, 2015
I'm not sure if this is the same error, but I've been getting similar weird behavior when using undo/redo in vim-mode. It seems to scatter lines all over the place, breaking them into seemingly random places. I can't get the correct state back afterwards. I'm not sure how to reproduce it consistently though.
maxbrunsfeld commentedon Jul 20, 2015
This is happening because of two things:
Rangeobject is passed toTextEditor::setTextInRange, that range object is stored in the text-editor's history.atom-joereusesRangeobjects, mutating their start and end points.The result is that the text-editor's history gets modified into an inconsistent state. I think that rewriting the
blockMovemethod as follows fixes the problem:We should probably be calling
Object.freezeon these (maybe all)Rangeobjects, since they are not intended to be mutated in this way./cc @nathansobo should
Rangesjust always be frozen?maxbrunsfeld commentedon Jul 20, 2015
By the way @iarna thanks for this very detailed report; I'm sorry that you had to deal with this confusing behavior. Please let me know if you're still working on
atom-joeand notice any other problems with the Atom API.nathansobo commentedon Jul 21, 2015
@maxbrunsfeld I do think we should freeze ranges and points as much as possible. I'm a bit concerned about the implications of doing it universally, since some packages mutate them for convenience. Starting with freezing stuff that goes into the history seems reasonable, and maybe exploring a way to freeze by default is also a good idea.
iarna commentedon Jul 21, 2015
\o/ Awesome, glad to see this fixed! I'm sure I will continue to do even weirder things w/ my little module, so w/ luck I'll help find some more of the hard to find corner cases. =)
lock commentedon Jan 21, 2019
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!