{"action":"closed","issue":{"url":"https://api.github.com/repos/Microsoft/vscode-languageserver-node/issues/129","repository_url":"https://api.github.com/repos/Microsoft/vscode-languageserver-node","labels_url":"https://api.github.com/repos/Microsoft/vscode-languageserver-node/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/vscode-languageserver-node/issues/129/comments","events_url":"https://api.github.com/repos/Microsoft/vscode-languageserver-node/issues/129/events","html_url":"https://github.com/Microsoft/vscode-languageserver-node/issues/129","id":190611313,"number":129,"title":"TextEdits are out of order","user":{"login":"gorkem","id":82738,"avatar_url":"https://avatars.githubusercontent.com/u/82738?v=3","gravatar_id":"","url":"https://api.github.com/users/gorkem","html_url":"https://github.com/gorkem","followers_url":"https://api.github.com/users/gorkem/followers","following_url":"https://api.github.com/users/gorkem/following{/other_user}","gists_url":"https://api.github.com/users/gorkem/gists{/gist_id}","starred_url":"https://api.github.com/users/gorkem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gorkem/subscriptions","organizations_url":"https://api.github.com/users/gorkem/orgs","repos_url":"https://api.github.com/users/gorkem/repos","events_url":"https://api.github.com/users/gorkem/events{/privacy}","received_events_url":"https://api.github.com/users/gorkem/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-21T03:39:41Z","updated_at":"2016-12-20T10:46:37Z","closed_at":"2016-12-20T10:46:37Z","body":"When the TextEdits that have been sent as part of the additionalTextEdits  on a completionItem applied the resulting didChange event sends the same edits on reverse order. The servers expect them on the order they were sent/applied.\r\n\r\nHere is the JSON trace for `completionItem/resolve` call for a completion Item just before it is applied. Notice the newline is the first item on the additionalTextEdits array. \r\n\r\n```json\r\nParams: {\r\n    \"label\": \"HashMap()\",\r\n    \"detail\": \"java.util.HashMap\",\r\n    \"insertText\": \"HashMap<>()\",\r\n    \"kind\": 4,\r\n    \"sortText\": \"fgd\",\r\n    \"additionalTextEdits\": [\r\n        {\r\n            \"range\": {\r\n                \"start\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                },\r\n                \"end\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                }\r\n            },\r\n            \"newText\": \"\\n\"\r\n        },\r\n        {\r\n            \"range\": {\r\n                \"start\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                },\r\n                \"end\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                }\r\n            },\r\n            \"newText\": \"import java.util.HashMap;\"\r\n        }\r\n    ],\r\n    \"data\": {\r\n        \"decl_signature\": \"Ljava.util.HashMap;\",\r\n        \"signature\": \"()V\",\r\n        \"name\": \"HashMap\",\r\n        \"uri\": \"file:/.../vertx-game-server/src/main/java/com/redhat/middleware/keynote/GameUtils.java\"\r\n    }\r\n}\r\n```\r\n\r\nThe resulting `'textDocument/didChange` notifications (2 change notifications are generated). Notice now the new line is the second element of the contentChanges array.\r\n\r\n```json\r\nParams: {\r\n    \"textDocument\": {\r\n        \"uri\": \"file:///.../vertx-game-server/src/main/java/com/redhat/middleware/keynote/GameUtils.java\",\r\n        \"version\": 34\r\n    },\r\n    \"contentChanges\": [\r\n        {\r\n            \"range\": {\r\n                \"start\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                },\r\n                \"end\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                }\r\n            },\r\n            \"rangeLength\": 0,\r\n            \"text\": \"import java.util.HashMap;\"\r\n        },\r\n        {\r\n            \"range\": {\r\n                \"start\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                },\r\n                \"end\": {\r\n                    \"line\": 3,\r\n                    \"character\": 20\r\n                }\r\n            },\r\n            \"rangeLength\": 0,\r\n            \"text\": \"\\n\"\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nAnother one for the main completionItem\r\n```json\r\nParams: {\r\n    \"textDocument\": {\r\n        \"uri\": \"file:///.../vertx-game-server/src/main/java/com/redhat/middleware/keynote/GameUtils.java\",\r\n        \"version\": 35\r\n    },\r\n    \"contentChanges\": [\r\n        {\r\n            \"range\": {\r\n                \"start\": {\r\n                    \"line\": 13,\r\n                    \"character\": 20\r\n                },\r\n                \"end\": {\r\n                    \"line\": 13,\r\n                    \"character\": 23\r\n                }\r\n            },\r\n            \"rangeLength\": 3,\r\n            \"text\": \"HashMap<>()\"\r\n        }\r\n    ]\r\n}\r\n```\r\nThis is related to\r\nhttps://github.com/redhat-developer/vscode-java/issues/87"}}
{"actor":{"display_login":"dbaeumer"}}