{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/40112213","id":40112213,"diff_hunk":"@@ -2357,19 +2363,52 @@ private static NormalizedSnapshotSpanCollection GetSelectionSpans(ITextView text\n                 return selection.SelectedSpans;\n             }\n \n+            /// <summary>\n+            /// REPL clipboard format.\n+            /// </summary>\n+            private const string ReplFormat = \"REPL\";\n+\n             private DataObject Copy(NormalizedSnapshotSpanCollection spans)\n             {\n-                var text = spans.Aggregate(new StringBuilder(), GetTextWithoutPrompts, b => b.ToString());\n+                var text = GetText(spans);\n+                var blocks = GetTextBlocks(spans);\n                 var rtf = _rtfBuilderService.GenerateRtf(spans, TextView);\n                 var data = new DataObject();\n                 data.SetData(DataFormats.StringFormat, text);\n                 data.SetData(DataFormats.Text, text);\n                 data.SetData(DataFormats.UnicodeText, text);\n                 data.SetData(DataFormats.Rtf, rtf);\n+                data.SetData(ReplFormat, blocks);\n                 return data;\n             }\n \n-            private StringBuilder GetTextWithoutPrompts(StringBuilder builder, SnapshotSpan span)\n+            /// <summary>\n+            /// Get the text of the given spans as a simple concatenated string.\n+            /// </summary>\n+            private static string GetText(NormalizedSnapshotSpanCollection spans)\n+            {\n+                var builder = new StringBuilder();\n+                foreach (var span in spans)\n+                {\n+                    builder.Append(span.GetText());\n+                }\n+                return builder.ToString();\n+            }\n+\n+            /// <summary>\n+            /// Get the text of the given spans as a serialized BufferBlock[].\n+            /// </summary>\n+            private string GetTextBlocks(NormalizedSnapshotSpanCollection spans)\n+            {\n+                var blocks = new List<BufferBlock>();\n+                foreach (var span in spans)\n+                {\n+                    GetTextBlocks(blocks, span);\n+                }\n+                return BufferBlock.Serialize(blocks.ToArray());\n+            }\n+\n+            private void GetTextBlocks(List<BufferBlock> blocks, SnapshotSpan span)\n             {\n                 // Find the range of source spans that cover the span.\n                 var sourceSpans = GetSourceSpans(span.Snapshot);","path":"src/InteractiveWindow/Editor/InteractiveWindow.UIThreadOnly.cs","position":67,"original_position":67,"commit_id":"11e79f2244ca12aaf9c6bbdf957ae9358ade95bb","original_commit_id":"11e79f2244ca12aaf9c6bbdf957ae9358ade95bb","user":{"login":"cston","id":10732005,"avatar_url":"https://avatars.githubusercontent.com/u/10732005?v=3","gravatar_id":"","url":"https://api.github.com/users/cston","html_url":"https://github.com/cston","followers_url":"https://api.github.com/users/cston/followers","following_url":"https://api.github.com/users/cston/following{/other_user}","gists_url":"https://api.github.com/users/cston/gists{/gist_id}","starred_url":"https://api.github.com/users/cston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cston/subscriptions","organizations_url":"https://api.github.com/users/cston/orgs","repos_url":"https://api.github.com/users/cston/repos","events_url":"https://api.github.com/users/cston/events{/privacy}","received_events_url":"https://api.github.com/users/cston/received_events","type":"User","site_admin":false},"body":"All spans should be from the same snapshot, although we don't control how the selection was set. Will leave as is for now.","created_at":"2015-09-22T16:58:52Z","updated_at":"2015-09-22T16:58:52Z","html_url":"https://github.com/dotnet/roslyn/pull/5387#discussion_r40112213","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/5387","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/40112213"},"html":{"href":"https://github.com/dotnet/roslyn/pull/5387#discussion_r40112213"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5387"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/5387","id":45628146,"html_url":"https://github.com/dotnet/roslyn/pull/5387","diff_url":"https://github.com/dotnet/roslyn/pull/5387.diff","patch_url":"https://github.com/dotnet/roslyn/pull/5387.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/5387","number":5387,"state":"open","locked":false,"title":"Copy/paste REPL clipboard format","user":{"login":"cston","id":10732005,"avatar_url":"https://avatars.githubusercontent.com/u/10732005?v=3","gravatar_id":"","url":"https://api.github.com/users/cston","html_url":"https://github.com/cston","followers_url":"https://api.github.com/users/cston/followers","following_url":"https://api.github.com/users/cston/following{/other_user}","gists_url":"https://api.github.com/users/cston/gists{/gist_id}","starred_url":"https://api.github.com/users/cston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cston/subscriptions","organizations_url":"https://api.github.com/users/cston/orgs","repos_url":"https://api.github.com/users/cston/repos","events_url":"https://api.github.com/users/cston/events{/privacy}","received_events_url":"https://api.github.com/users/cston/received_events","type":"User","site_admin":false},"body":"Copy all selected text to clipboard for Text and RTF formats and add a REPL format that contains the entire selection but differentiates inputs, outputs, and prompts. Paste uses the REPL format if it exists and pastes inputs and outputs but not prompts.","created_at":"2015-09-22T05:33:27Z","updated_at":"2015-09-22T16:58:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bdf4c32e084f04d8664893023f35426d10558edd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/5387/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/5387/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/5387/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/11e79f2244ca12aaf9c6bbdf957ae9358ade95bb","head":{"label":"cston:cp","ref":"cp","sha":"11e79f2244ca12aaf9c6bbdf957ae9358ade95bb","user":{"login":"cston","id":10732005,"avatar_url":"https://avatars.githubusercontent.com/u/10732005?v=3","gravatar_id":"","url":"https://api.github.com/users/cston","html_url":"https://github.com/cston","followers_url":"https://api.github.com/users/cston/followers","following_url":"https://api.github.com/users/cston/following{/other_user}","gists_url":"https://api.github.com/users/cston/gists{/gist_id}","starred_url":"https://api.github.com/users/cston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cston/subscriptions","organizations_url":"https://api.github.com/users/cston/orgs","repos_url":"https://api.github.com/users/cston/repos","events_url":"https://api.github.com/users/cston/events{/privacy}","received_events_url":"https://api.github.com/users/cston/received_events","type":"User","site_admin":false},"repo":{"id":30556803,"name":"roslyn","full_name":"cston/roslyn","owner":{"login":"cston","id":10732005,"avatar_url":"https://avatars.githubusercontent.com/u/10732005?v=3","gravatar_id":"","url":"https://api.github.com/users/cston","html_url":"https://github.com/cston","followers_url":"https://api.github.com/users/cston/followers","following_url":"https://api.github.com/users/cston/following{/other_user}","gists_url":"https://api.github.com/users/cston/gists{/gist_id}","starred_url":"https://api.github.com/users/cston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cston/subscriptions","organizations_url":"https://api.github.com/users/cston/orgs","repos_url":"https://api.github.com/users/cston/repos","events_url":"https://api.github.com/users/cston/events{/privacy}","received_events_url":"https://api.github.com/users/cston/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cston/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/cston/roslyn","forks_url":"https://api.github.com/repos/cston/roslyn/forks","keys_url":"https://api.github.com/repos/cston/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cston/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cston/roslyn/teams","hooks_url":"https://api.github.com/repos/cston/roslyn/hooks","issue_events_url":"https://api.github.com/repos/cston/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/cston/roslyn/events","assignees_url":"https://api.github.com/repos/cston/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/cston/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/cston/roslyn/tags","blobs_url":"https://api.github.com/repos/cston/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cston/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cston/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/cston/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cston/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/cston/roslyn/languages","stargazers_url":"https://api.github.com/repos/cston/roslyn/stargazers","contributors_url":"https://api.github.com/repos/cston/roslyn/contributors","subscribers_url":"https://api.github.com/repos/cston/roslyn/subscribers","subscription_url":"https://api.github.com/repos/cston/roslyn/subscription","commits_url":"https://api.github.com/repos/cston/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/cston/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/cston/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/cston/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/cston/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/cston/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cston/roslyn/merges","archive_url":"https://api.github.com/repos/cston/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cston/roslyn/downloads","issues_url":"https://api.github.com/repos/cston/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/cston/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/cston/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/cston/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cston/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/cston/roslyn/releases{/id}","created_at":"2015-02-09T20:26:55Z","updated_at":"2015-02-11T03:04:47Z","pushed_at":"2015-09-22T05:29:53Z","git_url":"git://github.com/cston/roslyn.git","ssh_url":"git@github.com:cston/roslyn.git","clone_url":"https://github.com/cston/roslyn.git","svn_url":"https://github.com/cston/roslyn","homepage":"","size":96741,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"f0713cfdabbf3f7247f3ec337350ef53c79302ca","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":29078997,"name":"roslyn","full_name":"dotnet/roslyn","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","created_at":"2015-01-11T02:39:03Z","updated_at":"2015-09-22T13:07:44Z","pushed_at":"2015-09-22T05:33:27Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":191317,"stargazers_count":3317,"watchers_count":3317,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":776,"mirror_url":null,"open_issues_count":1451,"forks":776,"open_issues":1451,"watchers":3317,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5387"},"html":{"href":"https://github.com/dotnet/roslyn/pull/5387"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/5387"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/5387/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5387/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/5387/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/11e79f2244ca12aaf9c6bbdf957ae9358ade95bb"}}}}