{"action":"created","comment":{"url":"https://api.github.com/repos/atom/line-top-index/pulls/comments/48004511","id":48004511,"diff_hunk":"@@ -69,53 +69,62 @@ export default class LineTopIndex {\n     let oldEnd = traverse(start, oldExtent)\n     let newEnd = traverse(start, newExtent)\n \n+    let isInsertion = isZero(oldExtent)\n     let startNode = this.iterator.insertNode(start)\n-    let endNode = this.iterator.insertNode(oldEnd)\n+    let endNode = this.iterator.insertNode(oldEnd, !isInsertion)\n \n     startNode.priority = -1\n     this.bubbleNodeUp(startNode)\n     endNode.priority = -2\n     this.bubbleNodeUp(endNode)\n \n-    if (startNode !== endNode) {\n-      let blockIdsToMove = new Set\n+    startNode.blockIds.forEach((id) => {\n+      if (!this.inclusiveBlockIds.has(id)) return\n \n-      startNode.blockIds.forEach((id) => {\n-        if (this.inclusiveBlockIds.has(id)) {\n-          startNode.blockIds.delete(id)\n-          blockIdsToMove.add(id)\n-        }\n-      })\n+      startNode.blockIds.delete(id)\n+      startNode.blockHeight -= this.blockHeightsById[id]\n+      startNode.distanceFromLeftAncestor.pixels -= this.blockHeightsById[id]\n \n-      if (startNode.right) {\n-        this.collectBlockIdsForSubtree(startNode.right, blockIdsToMove)\n-        startNode.right = null\n-      }\n+      endNode.blockIds.add(id)\n+      endNode.blockHeight += this.blockHeightsById[id]","path":"src/line-top-index.js","position":43,"original_position":43,"commit_id":"61f285ddb50a888d2a6e8c8c5b2b63cccde22887","original_commit_id":"61f285ddb50a888d2a6e8c8c5b2b63cccde22887","user":{"login":"as-cii","id":482957,"avatar_url":"https://avatars.githubusercontent.com/u/482957?v=3","gravatar_id":"","url":"https://api.github.com/users/as-cii","html_url":"https://github.com/as-cii","followers_url":"https://api.github.com/users/as-cii/followers","following_url":"https://api.github.com/users/as-cii/following{/other_user}","gists_url":"https://api.github.com/users/as-cii/gists{/gist_id}","starred_url":"https://api.github.com/users/as-cii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/as-cii/subscriptions","organizations_url":"https://api.github.com/users/as-cii/orgs","repos_url":"https://api.github.com/users/as-cii/repos","events_url":"https://api.github.com/users/as-cii/events{/privacy}","received_events_url":"https://api.github.com/users/as-cii/received_events","type":"User","site_admin":false},"body":"Yeah, another reason why I let this tiny bit of code to be duplicated is that I realized that we overlooked decrementing the height because we thought the two code paths were identical, whereas when we move stuff from `startNode` we need to perform some additional operations. Not sure if it's exactly accidental duplication, but I wasn't even sure the two code paths needed to evolve simultaneously.","created_at":"2015-12-18T08:40:25Z","updated_at":"2015-12-18T08:40:25Z","html_url":"https://github.com/atom/line-top-index/pull/2#discussion_r48004511","pull_request_url":"https://api.github.com/repos/atom/line-top-index/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/atom/line-top-index/pulls/comments/48004511"},"html":{"href":"https://github.com/atom/line-top-index/pull/2#discussion_r48004511"},"pull_request":{"href":"https://api.github.com/repos/atom/line-top-index/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/atom/line-top-index/pulls/2","id":53989282,"html_url":"https://github.com/atom/line-top-index/pull/2","diff_url":"https://github.com/atom/line-top-index/pull/2.diff","patch_url":"https://github.com/atom/line-top-index/pull/2.patch","issue_url":"https://api.github.com/repos/atom/line-top-index/issues/2","number":2,"state":"open","locked":false,"title":"Fix splicing on nodes which contain both inclusive and exclusive blocks","user":{"login":"as-cii","id":482957,"avatar_url":"https://avatars.githubusercontent.com/u/482957?v=3","gravatar_id":"","url":"https://api.github.com/users/as-cii","html_url":"https://github.com/as-cii","followers_url":"https://api.github.com/users/as-cii/followers","following_url":"https://api.github.com/users/as-cii/following{/other_user}","gists_url":"https://api.github.com/users/as-cii/gists{/gist_id}","starred_url":"https://api.github.com/users/as-cii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/as-cii/subscriptions","organizations_url":"https://api.github.com/users/as-cii/orgs","repos_url":"https://api.github.com/users/as-cii/repos","events_url":"https://api.github.com/users/as-cii/events{/privacy}","received_events_url":"https://api.github.com/users/as-cii/received_events","type":"User","site_admin":false},"body":"This fixes an issue where a node could contain both exclusive and inclusive nodes. \r\n\r\nWith the previous approach, when the start node coincided with the end node, we basically moved both to the new end position, thereby causing both inclusive and exclusive markers to be moved. This PR changes it so that we create a new node at the `oldEnd` when there is an insertion, so that the two kinds of markers can be moved independently.\r\n\r\nI am opening a PR because it's the first big change I make to this code and I'd love to have another pair of :eyes: before committing to master.\r\n\r\n/cc: @nathansobo ","created_at":"2015-12-17T15:23:04Z","updated_at":"2015-12-18T08:40:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ee05b46d16e60356a953f52c4a7d24a1eccbb56","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/atom/line-top-index/pulls/2/commits","review_comments_url":"https://api.github.com/repos/atom/line-top-index/pulls/2/comments","review_comment_url":"https://api.github.com/repos/atom/line-top-index/pulls/comments{/number}","comments_url":"https://api.github.com/repos/atom/line-top-index/issues/2/comments","statuses_url":"https://api.github.com/repos/atom/line-top-index/statuses/61f285ddb50a888d2a6e8c8c5b2b63cccde22887","head":{"label":"atom:as-fix-splice-with-inclusive-exclusive-blocks","ref":"as-fix-splice-with-inclusive-exclusive-blocks","sha":"61f285ddb50a888d2a6e8c8c5b2b63cccde22887","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":47418778,"name":"line-top-index","full_name":"atom/line-top-index","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/line-top-index","description":null,"fork":false,"url":"https://api.github.com/repos/atom/line-top-index","forks_url":"https://api.github.com/repos/atom/line-top-index/forks","keys_url":"https://api.github.com/repos/atom/line-top-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/line-top-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/line-top-index/teams","hooks_url":"https://api.github.com/repos/atom/line-top-index/hooks","issue_events_url":"https://api.github.com/repos/atom/line-top-index/issues/events{/number}","events_url":"https://api.github.com/repos/atom/line-top-index/events","assignees_url":"https://api.github.com/repos/atom/line-top-index/assignees{/user}","branches_url":"https://api.github.com/repos/atom/line-top-index/branches{/branch}","tags_url":"https://api.github.com/repos/atom/line-top-index/tags","blobs_url":"https://api.github.com/repos/atom/line-top-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/line-top-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/line-top-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/line-top-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/line-top-index/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/line-top-index/languages","stargazers_url":"https://api.github.com/repos/atom/line-top-index/stargazers","contributors_url":"https://api.github.com/repos/atom/line-top-index/contributors","subscribers_url":"https://api.github.com/repos/atom/line-top-index/subscribers","subscription_url":"https://api.github.com/repos/atom/line-top-index/subscription","commits_url":"https://api.github.com/repos/atom/line-top-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/line-top-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/line-top-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/line-top-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/atom/line-top-index/contents/{+path}","compare_url":"https://api.github.com/repos/atom/line-top-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/line-top-index/merges","archive_url":"https://api.github.com/repos/atom/line-top-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/line-top-index/downloads","issues_url":"https://api.github.com/repos/atom/line-top-index/issues{/number}","pulls_url":"https://api.github.com/repos/atom/line-top-index/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/line-top-index/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/line-top-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/line-top-index/labels{/name}","releases_url":"https://api.github.com/repos/atom/line-top-index/releases{/id}","created_at":"2015-12-04T17:22:44Z","updated_at":"2015-12-04T17:22:56Z","pushed_at":"2015-12-17T15:37:08Z","git_url":"git://github.com/atom/line-top-index.git","ssh_url":"git@github.com:atom/line-top-index.git","clone_url":"https://github.com/atom/line-top-index.git","svn_url":"https://github.com/atom/line-top-index","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"atom:master","ref":"master","sha":"63aeebb57193982e6a9dfa88c99a2b552d375039","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":47418778,"name":"line-top-index","full_name":"atom/line-top-index","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/line-top-index","description":null,"fork":false,"url":"https://api.github.com/repos/atom/line-top-index","forks_url":"https://api.github.com/repos/atom/line-top-index/forks","keys_url":"https://api.github.com/repos/atom/line-top-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/line-top-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/line-top-index/teams","hooks_url":"https://api.github.com/repos/atom/line-top-index/hooks","issue_events_url":"https://api.github.com/repos/atom/line-top-index/issues/events{/number}","events_url":"https://api.github.com/repos/atom/line-top-index/events","assignees_url":"https://api.github.com/repos/atom/line-top-index/assignees{/user}","branches_url":"https://api.github.com/repos/atom/line-top-index/branches{/branch}","tags_url":"https://api.github.com/repos/atom/line-top-index/tags","blobs_url":"https://api.github.com/repos/atom/line-top-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/line-top-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/line-top-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/line-top-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/line-top-index/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/line-top-index/languages","stargazers_url":"https://api.github.com/repos/atom/line-top-index/stargazers","contributors_url":"https://api.github.com/repos/atom/line-top-index/contributors","subscribers_url":"https://api.github.com/repos/atom/line-top-index/subscribers","subscription_url":"https://api.github.com/repos/atom/line-top-index/subscription","commits_url":"https://api.github.com/repos/atom/line-top-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/line-top-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/line-top-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/line-top-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/atom/line-top-index/contents/{+path}","compare_url":"https://api.github.com/repos/atom/line-top-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/line-top-index/merges","archive_url":"https://api.github.com/repos/atom/line-top-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/line-top-index/downloads","issues_url":"https://api.github.com/repos/atom/line-top-index/issues{/number}","pulls_url":"https://api.github.com/repos/atom/line-top-index/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/line-top-index/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/line-top-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/line-top-index/labels{/name}","releases_url":"https://api.github.com/repos/atom/line-top-index/releases{/id}","created_at":"2015-12-04T17:22:44Z","updated_at":"2015-12-04T17:22:56Z","pushed_at":"2015-12-17T15:37:08Z","git_url":"git://github.com/atom/line-top-index.git","ssh_url":"git@github.com:atom/line-top-index.git","clone_url":"https://github.com/atom/line-top-index.git","svn_url":"https://github.com/atom/line-top-index","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atom/line-top-index/pulls/2"},"html":{"href":"https://github.com/atom/line-top-index/pull/2"},"issue":{"href":"https://api.github.com/repos/atom/line-top-index/issues/2"},"comments":{"href":"https://api.github.com/repos/atom/line-top-index/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/atom/line-top-index/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/atom/line-top-index/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/atom/line-top-index/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/atom/line-top-index/statuses/61f285ddb50a888d2a6e8c8c5b2b63cccde22887"}}}}