{"action":"created","comment":{"url":"https://api.github.com/repos/google/xi-editor/pulls/comments/115812121","pull_request_review_id":37384109,"id":115812121,"diff_hunk":"@@ -145,27 +159,65 @@ impl<N: NodeInfo> Delta<N> {\n         Delta { els: els, base_len: base_len }\n     }\n \n+    /// Produce a summary of the delta. Everything outside the returned interval\n+    /// is unchanged, and the old contents of the interval are replaced by new\n+    /// contents of the returned length. Equations:\n+    ///\n+    /// `(iv, new_len) = self.summary()`\n+    ///\n+    /// `new_s = self.apply(s)`\n+    ///\n+    /// `new_s = simple_edit(iv, new_s.subseq(iv.start(), iv.start() + new_len), s.len()).apply(s)`\n+    pub fn summary(&self) -> (Interval, usize) {\n+        let mut els = self.els.as_slice();\n+        let mut iv_start = 0;\n+        if let Some((&DeltaElement::Copy(0, end), rest)) = els.split_first() {\n+            iv_start = end;\n+            els = rest;\n+        }\n+        let mut iv_end = self.base_len;\n+        if let Some((&DeltaElement::Copy(beg, end), init)) = els.split_last() {\n+            if end == iv_end {\n+                iv_end = beg;\n+                els = init;\n+            }\n+        }\n+        (Interval::new_closed_open(iv_start, iv_end), Delta::els_len(els))\n+    }\n+\n+    fn els_len(els: &[DeltaElement<N>]) -> usize {","path":"rust/rope/src/delta.rs","position":106,"original_position":106,"commit_id":"894af29a7976c245b94b2bca1e2f1cfa6d1f6803","original_commit_id":"6b1e71a40b680fe32b721fa6f9620122fb016a57","user":{"login":"raphlinus","id":242367,"avatar_url":"https://avatars0.githubusercontent.com/u/242367?v=3","gravatar_id":"","url":"https://api.github.com/users/raphlinus","html_url":"https://github.com/raphlinus","followers_url":"https://api.github.com/users/raphlinus/followers","following_url":"https://api.github.com/users/raphlinus/following{/other_user}","gists_url":"https://api.github.com/users/raphlinus/gists{/gist_id}","starred_url":"https://api.github.com/users/raphlinus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphlinus/subscriptions","organizations_url":"https://api.github.com/users/raphlinus/orgs","repos_url":"https://api.github.com/users/raphlinus/repos","events_url":"https://api.github.com/users/raphlinus/events{/privacy}","received_events_url":"https://api.github.com/users/raphlinus/received_events","type":"User","site_admin":false},"body":"Doc (and possible rename): this method returns the length of the transformed string.","created_at":"2017-05-10T18:07:39Z","updated_at":"2017-05-10T18:21:45Z","html_url":"https://github.com/google/xi-editor/pull/277#discussion_r115812121","pull_request_url":"https://api.github.com/repos/google/xi-editor/pulls/277","_links":{"self":{"href":"https://api.github.com/repos/google/xi-editor/pulls/comments/115812121"},"html":{"href":"https://github.com/google/xi-editor/pull/277#discussion_r115812121"},"pull_request":{"href":"https://api.github.com/repos/google/xi-editor/pulls/277"}}},"pull_request":{"url":"https://api.github.com/repos/google/xi-editor/pulls/277","id":119571128,"html_url":"https://github.com/google/xi-editor/pull/277","diff_url":"https://github.com/google/xi-editor/pull/277.diff","patch_url":"https://github.com/google/xi-editor/pull/277.patch","issue_url":"https://api.github.com/repos/google/xi-editor/issues/277","number":277,"state":"open","locked":false,"title":"Refactor Engine, fixes #256","user":{"login":"trishume","id":887610,"avatar_url":"https://avatars2.githubusercontent.com/u/887610?v=3","gravatar_id":"","url":"https://api.github.com/users/trishume","html_url":"https://github.com/trishume","followers_url":"https://api.github.com/users/trishume/followers","following_url":"https://api.github.com/users/trishume/following{/other_user}","gists_url":"https://api.github.com/users/trishume/gists{/gist_id}","starred_url":"https://api.github.com/users/trishume/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trishume/subscriptions","organizations_url":"https://api.github.com/users/trishume/orgs","repos_url":"https://api.github.com/users/trishume/repos","events_url":"https://api.github.com/users/trishume/events{/privacy}","received_events_url":"https://api.github.com/users/trishume/received_events","type":"User","site_admin":false},"body":"This PR contains a number of related refactorings to the `Engine`, `Delta` and `Subset` classes. It is entirely re-namings, doc comment changes, and one removal of a duplicate method. Split into multiple commits according to which refactors must occur together, you may want to review each commit individually. Fixes #256, see discussion there for context.\r\n\r\ncc @raphlinus \r\n\r\nI've pasted the commit message of the most significant refactoring below:\r\n\r\n### Rename methods of Subset to be more consistent.\r\n\r\nThere was previously an inconsistency in the naming in Engine and the naming\r\nin Subset. See #256\r\n\r\nThe naming of the methods of Subset was as if the Subset represented\r\nthe complement of the ranges it contained, which if the ranges were deletions\r\nmeant it represented the elements that were kept.\r\n\r\nHowever, this was inconsistent with the naming in Engine which had subsets like\r\n`inserts` and `deletes` that according to the concept of Subset actually represented\r\nthe non-inserted and non-deleted ranges.\r\n\r\nThis fixes the inconsistency by renaming methods as if Subset just represents the\r\nranges it contains, which eliminates having to reason about the complement when\r\nthinking about the entire system.","created_at":"2017-05-09T02:19:14Z","updated_at":"2017-05-10T18:21:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59d0f98133a4da33a585728f40d16617b26f2e6e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/xi-editor/pulls/277/commits","review_comments_url":"https://api.github.com/repos/google/xi-editor/pulls/277/comments","review_comment_url":"https://api.github.com/repos/google/xi-editor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/xi-editor/issues/277/comments","statuses_url":"https://api.github.com/repos/google/xi-editor/statuses/894af29a7976c245b94b2bca1e2f1cfa6d1f6803","head":{"label":"google:refactor-engine","ref":"refactor-engine","sha":"894af29a7976c245b94b2bca1e2f1cfa6d1f6803","user":{"login":"google","id":1342004,"avatar_url":"https://avatars2.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":57167764,"name":"xi-editor","full_name":"google/xi-editor","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars2.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/xi-editor","description":"A modern editor with a backend written in Rust.","fork":false,"url":"https://api.github.com/repos/google/xi-editor","forks_url":"https://api.github.com/repos/google/xi-editor/forks","keys_url":"https://api.github.com/repos/google/xi-editor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/xi-editor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/xi-editor/teams","hooks_url":"https://api.github.com/repos/google/xi-editor/hooks","issue_events_url":"https://api.github.com/repos/google/xi-editor/issues/events{/number}","events_url":"https://api.github.com/repos/google/xi-editor/events","assignees_url":"https://api.github.com/repos/google/xi-editor/assignees{/user}","branches_url":"https://api.github.com/repos/google/xi-editor/branches{/branch}","tags_url":"https://api.github.com/repos/google/xi-editor/tags","blobs_url":"https://api.github.com/repos/google/xi-editor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/xi-editor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/xi-editor/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/xi-editor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/xi-editor/statuses/{sha}","languages_url":"https://api.github.com/repos/google/xi-editor/languages","stargazers_url":"https://api.github.com/repos/google/xi-editor/stargazers","contributors_url":"https://api.github.com/repos/google/xi-editor/contributors","subscribers_url":"https://api.github.com/repos/google/xi-editor/subscribers","subscription_url":"https://api.github.com/repos/google/xi-editor/subscription","commits_url":"https://api.github.com/repos/google/xi-editor/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/xi-editor/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/xi-editor/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/xi-editor/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/xi-editor/contents/{+path}","compare_url":"https://api.github.com/repos/google/xi-editor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/xi-editor/merges","archive_url":"https://api.github.com/repos/google/xi-editor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/xi-editor/downloads","issues_url":"https://api.github.com/repos/google/xi-editor/issues{/number}","pulls_url":"https://api.github.com/repos/google/xi-editor/pulls{/number}","milestones_url":"https://api.github.com/repos/google/xi-editor/milestones{/number}","notifications_url":"https://api.github.com/repos/google/xi-editor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/xi-editor/labels{/name}","releases_url":"https://api.github.com/repos/google/xi-editor/releases{/id}","deployments_url":"https://api.github.com/repos/google/xi-editor/deployments","created_at":"2016-04-26T23:03:23Z","updated_at":"2017-05-10T17:29:29Z","pushed_at":"2017-05-10T18:09:03Z","git_url":"git://github.com/google/xi-editor.git","ssh_url":"git@github.com:google/xi-editor.git","clone_url":"https://github.com/google/xi-editor.git","svn_url":"https://github.com/google/xi-editor","homepage":"","size":1692,"stargazers_count":7810,"watchers_count":7810,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":256,"mirror_url":null,"open_issues_count":82,"forks":256,"open_issues":82,"watchers":7810,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"c004875b34409d1547a66a9c1d6f8c1b87f019a5","user":{"login":"google","id":1342004,"avatar_url":"https://avatars2.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":57167764,"name":"xi-editor","full_name":"google/xi-editor","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars2.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/xi-editor","description":"A modern editor with a backend written in Rust.","fork":false,"url":"https://api.github.com/repos/google/xi-editor","forks_url":"https://api.github.com/repos/google/xi-editor/forks","keys_url":"https://api.github.com/repos/google/xi-editor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/xi-editor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/xi-editor/teams","hooks_url":"https://api.github.com/repos/google/xi-editor/hooks","issue_events_url":"https://api.github.com/repos/google/xi-editor/issues/events{/number}","events_url":"https://api.github.com/repos/google/xi-editor/events","assignees_url":"https://api.github.com/repos/google/xi-editor/assignees{/user}","branches_url":"https://api.github.com/repos/google/xi-editor/branches{/branch}","tags_url":"https://api.github.com/repos/google/xi-editor/tags","blobs_url":"https://api.github.com/repos/google/xi-editor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/xi-editor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/xi-editor/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/xi-editor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/xi-editor/statuses/{sha}","languages_url":"https://api.github.com/repos/google/xi-editor/languages","stargazers_url":"https://api.github.com/repos/google/xi-editor/stargazers","contributors_url":"https://api.github.com/repos/google/xi-editor/contributors","subscribers_url":"https://api.github.com/repos/google/xi-editor/subscribers","subscription_url":"https://api.github.com/repos/google/xi-editor/subscription","commits_url":"https://api.github.com/repos/google/xi-editor/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/xi-editor/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/xi-editor/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/xi-editor/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/xi-editor/contents/{+path}","compare_url":"https://api.github.com/repos/google/xi-editor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/xi-editor/merges","archive_url":"https://api.github.com/repos/google/xi-editor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/xi-editor/downloads","issues_url":"https://api.github.com/repos/google/xi-editor/issues{/number}","pulls_url":"https://api.github.com/repos/google/xi-editor/pulls{/number}","milestones_url":"https://api.github.com/repos/google/xi-editor/milestones{/number}","notifications_url":"https://api.github.com/repos/google/xi-editor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/xi-editor/labels{/name}","releases_url":"https://api.github.com/repos/google/xi-editor/releases{/id}","deployments_url":"https://api.github.com/repos/google/xi-editor/deployments","created_at":"2016-04-26T23:03:23Z","updated_at":"2017-05-10T17:29:29Z","pushed_at":"2017-05-10T18:09:03Z","git_url":"git://github.com/google/xi-editor.git","ssh_url":"git@github.com:google/xi-editor.git","clone_url":"https://github.com/google/xi-editor.git","svn_url":"https://github.com/google/xi-editor","homepage":"","size":1692,"stargazers_count":7810,"watchers_count":7810,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":256,"mirror_url":null,"open_issues_count":82,"forks":256,"open_issues":82,"watchers":7810,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/xi-editor/pulls/277"},"html":{"href":"https://github.com/google/xi-editor/pull/277"},"issue":{"href":"https://api.github.com/repos/google/xi-editor/issues/277"},"comments":{"href":"https://api.github.com/repos/google/xi-editor/issues/277/comments"},"review_comments":{"href":"https://api.github.com/repos/google/xi-editor/pulls/277/comments"},"review_comment":{"href":"https://api.github.com/repos/google/xi-editor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/xi-editor/pulls/277/commits"},"statuses":{"href":"https://api.github.com/repos/google/xi-editor/statuses/894af29a7976c245b94b2bca1e2f1cfa6d1f6803"}}}}
{"actor":{"display_login":"raphlinus"}}