{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/8368","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/8368/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/8368/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/8368/events","html_url":"https://github.com/dotnet/roslyn/issues/8368","id":131108878,"number":8368,"title":"Rename action asks to rename wrong name if you undo changes","user":{"login":"dpoeschl","id":235241,"avatar_url":"https://avatars.githubusercontent.com/u/235241?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoeschl","html_url":"https://github.com/dpoeschl","followers_url":"https://api.github.com/users/dpoeschl/followers","following_url":"https://api.github.com/users/dpoeschl/following{/other_user}","gists_url":"https://api.github.com/users/dpoeschl/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoeschl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoeschl/subscriptions","organizations_url":"https://api.github.com/users/dpoeschl/orgs","repos_url":"https://api.github.com/users/dpoeschl/repos","events_url":"https://api.github.com/users/dpoeschl/events{/privacy}","received_events_url":"https://api.github.com/users/dpoeschl/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-IDE","name":"Area-IDE","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Bug","name":"Bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/2","html_url":"https://github.com/dotnet/roslyn/milestones/Unknown","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/2/labels","id":937398,"number":2,"title":"Unknown","description":"This represents work which is not planned for a specific release.\r\n\r\n<!---\r\n@huboard:{\"order\":0.25}\n-->\r\n","creator":{"login":"jaredpar","id":146967,"avatar_url":"https://avatars.githubusercontent.com/u/146967?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"open_issues":484,"closed_issues":98,"state":"open","created_at":"2015-01-15T20:46:02Z","updated_at":"2016-02-03T18:12:47Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-02-03T18:12:47Z","updated_at":"2016-02-03T18:13:11Z","closed_at":null,"body":"Ported from internal bug 130102\r\n\r\nIf you type in the wrong name for a parameter, commit it , then undo those changes, then rename it again, the rename action tries to rename from the name that you undid.\r\n\r\nI expected that the rename action to never suggest changes that I've undone."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/179385398","html_url":"https://github.com/dotnet/roslyn/issues/8368#issuecomment-179385398","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/8368","id":179385398,"user":{"login":"dpoeschl","id":235241,"avatar_url":"https://avatars.githubusercontent.com/u/235241?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoeschl","html_url":"https://github.com/dpoeschl","followers_url":"https://api.github.com/users/dpoeschl/followers","following_url":"https://api.github.com/users/dpoeschl/following{/other_user}","gists_url":"https://api.github.com/users/dpoeschl/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoeschl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoeschl/subscriptions","organizations_url":"https://api.github.com/users/dpoeschl/orgs","repos_url":"https://api.github.com/users/dpoeschl/repos","events_url":"https://api.github.com/users/dpoeschl/events{/privacy}","received_events_url":"https://api.github.com/users/dpoeschl/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T18:13:11Z","updated_at":"2016-02-03T18:13:11Z","body":"Clearing the state on undo causes tracking to be dismissed during some valid sessions. All consecutive forward typing is undone at once, but any intervening backspaces split up the undo stack. So if you have \"abc$$\" and type \"def<backspace><backspace>ghi\" you have 4 items on the undo stack before getting back to abc (removing the \"ghi\", adding back the 'e', adding back the 'f', and finally removing the \"def\").\r\n\r\nThings go awry because a space is typed after the renamed identifier which dismisses the session. Then, the undo process actually undoes one character at a time (one ITextBuffer.Changed for each). The first removes the space that was added (which keeps the tracking session clear), and the subsequent ones remove characters one at a time from the end, which looks like a valid session. If instead we were able to get one ITextBuffer.Changed notification for the entire undo, the session would actually clear itself because the removed text would have included the space at the end, which makes the delta invalid & clears the state.\r\n\r\nProposal: We could try to briefly keep tracking sessions around after they've been cleared, and if a buffer edit comes in that exactly undoes the immediately prior change then we restore the session where it was. This would handle the case in the video, but also cases where the user bumps , or ; or whatever while typing and immediately backspaces it away."}}