{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/49114","repository_url":"https://api.github.com/repos/Microsoft/vscode","labels_url":"https://api.github.com/repos/Microsoft/vscode/issues/49114/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/vscode/issues/49114/comments","events_url":"https://api.github.com/repos/Microsoft/vscode/issues/49114/events","html_url":"https://github.com/Microsoft/vscode/issues/49114","id":319885739,"number":49114,"title":"Support applying WorkspaceEdit/editBuilder changes sequentially (and/or document current behaviour)","user":{"login":"DanTup","id":1078012,"avatar_url":"https://avatars2.githubusercontent.com/u/1078012?v=4","gravatar_id":"","url":"https://api.github.com/users/DanTup","html_url":"https://github.com/DanTup","followers_url":"https://api.github.com/users/DanTup/followers","following_url":"https://api.github.com/users/DanTup/following{/other_user}","gists_url":"https://api.github.com/users/DanTup/gists{/gist_id}","starred_url":"https://api.github.com/users/DanTup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanTup/subscriptions","organizations_url":"https://api.github.com/users/DanTup/orgs","repos_url":"https://api.github.com/users/DanTup/repos","events_url":"https://api.github.com/users/DanTup/events{/privacy}","received_events_url":"https://api.github.com/users/DanTup/received_events","type":"User","site_admin":false},"labels":[{"id":294817667,"url":"https://api.github.com/repos/Microsoft/vscode/labels/editor","name":"editor","color":"1d76db","default":false},{"id":425577013,"url":"https://api.github.com/repos/Microsoft/vscode/labels/editor-core","name":"editor-core","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":{"login":"jrieken","id":1794099,"avatar_url":"https://avatars2.githubusercontent.com/u/1794099?v=4","gravatar_id":"","url":"https://api.github.com/users/jrieken","html_url":"https://github.com/jrieken","followers_url":"https://api.github.com/users/jrieken/followers","following_url":"https://api.github.com/users/jrieken/following{/other_user}","gists_url":"https://api.github.com/users/jrieken/gists{/gist_id}","starred_url":"https://api.github.com/users/jrieken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrieken/subscriptions","organizations_url":"https://api.github.com/users/jrieken/orgs","repos_url":"https://api.github.com/users/jrieken/repos","events_url":"https://api.github.com/users/jrieken/events{/privacy}","received_events_url":"https://api.github.com/users/jrieken/received_events","type":"User","site_admin":false},"assignees":[{"login":"jrieken","id":1794099,"avatar_url":"https://avatars2.githubusercontent.com/u/1794099?v=4","gravatar_id":"","url":"https://api.github.com/users/jrieken","html_url":"https://github.com/jrieken","followers_url":"https://api.github.com/users/jrieken/followers","following_url":"https://api.github.com/users/jrieken/following{/other_user}","gists_url":"https://api.github.com/users/jrieken/gists{/gist_id}","starred_url":"https://api.github.com/users/jrieken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrieken/subscriptions","organizations_url":"https://api.github.com/users/jrieken/orgs","repos_url":"https://api.github.com/users/jrieken/repos","events_url":"https://api.github.com/users/jrieken/events{/privacy}","received_events_url":"https://api.github.com/users/jrieken/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-05-03T11:42:11Z","updated_at":"2018-05-04T11:56:52Z","closed_at":null,"author_association":"NONE","body":"If you have a file like this:\r\n\r\n```text\r\nORIG 1\r\nORIG 2\r\nORIG 3\r\n```\r\n\r\nAnd you run this code:\r\n\r\n```ts\r\nconst changes = new vs.WorkspaceEdit();\r\n// Insert some text on line 1\r\nchanges.replace(document.uri, new vs.Range(new vs.Position(0, 0), new vs.Position(0, 0)), \"LINE 1\\n\");\r\n// Insert some text on line 2\r\nchanges.replace(document.uri, new vs.Range(new vs.Position(1, 0), new vs.Position(1, 0)), \"LINE 2\\n\");\r\n// Insert some text on line 3\r\nchanges.replace(document.uri, new vs.Range(new vs.Position(2, 0), new vs.Position(2, 0)), \"LINE 3\\n\");\r\nawait vs.workspace.applyEdit(changes);\r\n```\r\n\r\nThe final line inserted \"LINE 3\" ends up on line 5. This is (presumably) because VS Code is working out which locations to make the changes before applying any of them, then applying them all.\r\n\r\nThe Dart analysis server doesn't work this way; it provides a bunch of edits with the assumption that they'll be applied sequentially (so offsets are already adjusted for earlier changes in the list).\r\n\r\nWhile it's fixable by using multiple WorkspaceEdits, you lose the \"all or nothing\" functionality provided by WorkspaceEdit and would have do manually roll changes back if one fails.\r\n\r\nI think it'd be nice to support (both for WorkspaceEdit and editBuilder) allowing pre-adjusted offsets. If not, the docs should at least call out this behaviour so the it's clear to users that multiple edits inside a `WorkspaceEdit` will not have the same effect as multiple sequentially-applied `WorkspaceEdit`s."},"comment":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/comments/386578980","html_url":"https://github.com/Microsoft/vscode/issues/49114#issuecomment-386578980","issue_url":"https://api.github.com/repos/Microsoft/vscode/issues/49114","id":386578980,"user":{"login":"jrieken","id":1794099,"avatar_url":"https://avatars2.githubusercontent.com/u/1794099?v=4","gravatar_id":"","url":"https://api.github.com/users/jrieken","html_url":"https://github.com/jrieken","followers_url":"https://api.github.com/users/jrieken/followers","following_url":"https://api.github.com/users/jrieken/following{/other_user}","gists_url":"https://api.github.com/users/jrieken/gists{/gist_id}","starred_url":"https://api.github.com/users/jrieken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrieken/subscriptions","organizations_url":"https://api.github.com/users/jrieken/orgs","repos_url":"https://api.github.com/users/jrieken/repos","events_url":"https://api.github.com/users/jrieken/events{/privacy}","received_events_url":"https://api.github.com/users/jrieken/received_events","type":"User","site_admin":false},"created_at":"2018-05-04T11:56:52Z","updated_at":"2018-05-04T11:56:52Z","author_association":"MEMBER","body":"> The Dart analysis server doesn't work this way; it provides a bunch of edits with the assumption that they'll be applied sequentially (so offsets are already adjusted for earlier changes in the list).\r\n\r\nInteresting. I'd say the likelihood of us changing how edits are applied is low, not to say very, very low. Yeah, you can fire sequential edits (which isn't proper), talk to your server-folks, or do the merge math inside your extension. "}}
{"actor":{"display_login":"jrieken"}}