-
Notifications
You must be signed in to change notification settings - Fork 37.2k
#198975: saveValue => historyNavigator.add #199142
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
Conversation
DanielFrantes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all looks fine
|
|
The problem with this fix is that you could end up saving in history a message which was never used for committing:
🐛 Now the history will have A, C, Z, B, but Z should not have been stored. |
|
That being said, I don't really have a better idea right now other than a large refactoring, so I'd gladly take that bug over the original data loss bug. |
Fixes #198975.
Problem
Consider how scmService.setValue works
Following is a typical user flow and what happens under the hood
Please consider the following two data structures which are used-
HistoryNavigator = [Msg1, Msg2, Msg3, Msg4, Msg5, ]
scmService._value = "<empty string"
Considering the case of undo commit, a major difference is that this is the only time when setValue is called with transient = false and the passed-value is an actual message (and not an empty string).
So, with undo commit, the undone-commit-message is passed as a value. This in-turn causes the undone-commit message to sit at the end of the history navigator and also in the _value member.
If anytime after this a setValue is called with transient = false, this would cause the last item in history navigator (which is the undone-commit-message) to be overwritten and hence lost.
Here is an example showing the same.
Lets assume the history looks like this [Msg1, Msg2, Msg3, Msg4, Msg5, ]
Fix
The fix for this would be to modify the implementation of setValue when transient = false. Instead of replacing the last value in historyNavigator with the passed-in value we just need to add the passed-in value as another node. This would handle all the cases.
Testing
Tested these manually-
Unit Tests
9175 passing (2m)
60 pending