{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/32184","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/32184/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/32184/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/32184/events","html_url":"https://github.com/dart-lang/sdk/issues/32184","id":297501042,"number":32184,"title":"Incorrect `selection` returned in quick fixes from analysis server","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":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-15T16:05:16Z","updated_at":"2018-02-15T16:31:34Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Copied from https://github.com/Dart-Code/Dart-Code/issues/573\r\n\r\nWe're using the `selection` that comes back with the assist, but it seems to be at the end of the inserted text.\r\n\r\nExample:\r\n\r\n```dart\r\nimport 'package:flutter/material.dart';\r\n\r\nclass Danny extends StatelessWidget {\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return const Center(child: const Text('test'));\r\n  }\r\n}\r\n```\r\n\r\nI put my cursor in the middle of the word `Center` (position 155) and invoke \"Add widget padding\":\r\n\r\n```js\r\n{\"id\":\"15\",\"method\":\"edit.getAssists\",\"params\":{\"file\":\"m:\\\\Coding\\\\Applications\\\\flutter\\\\examples\\\\stocks\\\\lib\\\\danny.dart\",\"length\":0,\"offset\":155}}\r\n```\r\n\r\nThe assist comes back like this:\r\n\r\n```js\r\n{\r\n\t\"message\": \"Add widget padding\",\r\n\t\"edits\": [\r\n\t\t{\r\n\t\t\t\"file\": \"m:\\\\Coding\\\\Applications\\\\flutter\\\\examples\\\\stocks\\\\lib\\\\danny.dart\",\r\n\t\t\t\"fileStamp\": 0,\r\n\t\t\t\"edits\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"offset\": 146,\r\n\t\t\t\t\t\"length\": 39,\r\n\t\t\t\t\t\"replacement\": \"new Padding(\\r\\n      padding: const EdgeInsets.all(8.0),\\r\\n      child: const Center(child: const Text('test')),\\r\\n    )\"\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t}\r\n\t],\r\n\t\"linkedEditGroups\": [],\r\n\t\"selection\": {\r\n\t\t\"file\": \"m:\\\\Coding\\\\Applications\\\\flutter\\\\examples\\\\stocks\\\\lib\\\\danny.dart\",\r\n\t\t\"offset\": 263\r\n\t}\r\n}\r\n```\r\n\r\nThe final doc looks like this:\r\n\r\n```dart\r\nimport 'package:flutter/material.dart';\r\n\r\nclass Danny extends StatelessWidget {\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return new Padding(\r\n      padding: const EdgeInsets.all(8.0),\r\n      child: const Center(child: const Text('test')),\r\n    );\r\n  }\r\n}\r\n```\r\n\r\nThe selection given was 263, which is where the `);` is but we would expect it to remain in the middle of the word `Center` (225/226?)."},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/365982885","html_url":"https://github.com/dart-lang/sdk/issues/32184#issuecomment-365982885","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/32184","id":365982885,"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},"created_at":"2018-02-15T16:31:34Z","updated_at":"2018-02-15T16:31:34Z","author_association":"CONTRIBUTOR","body":"Personally, I think when wrapping with a widget, I'd prefer the cursor to stay on the same constructor it was before. I'm not so sure about if you were doing \"swap with parent\" etc. though.\r\n\r\nThat said; I think both of your suggestions would be reasonable, I don't think either would feel like a bug as the current behaviour does."}}
{"actor":{"display_login":"DanTup"}}