{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/35598434","id":35598434,"diff_hunk":"@@ -260,50 +260,58 @@ private Dispatcher Dispatcher\n \n         private void SubmissionBufferAdded(object sender, SubmissionBufferAddedEventArgs args)\n         {\n-            AddSubmission(_currentWindow.TextView, args.NewBuffer);\n+            AddSubmission(_currentWindow.TextView, args.NewBuffer, this.LanguageName);\n         }\n \n         // The REPL window might change content type to host command content type (when a host command is typed at the beginning of the buffer).\n         private void LanguageBufferContentTypeChanged(object sender, ContentTypeChangedEventArgs e)\n         {\n-            var buffer = e.Before.TextBuffer;\n-            var afterIsCSharp = e.AfterContentType.IsOfType(ContentTypeNames.CSharpContentType);\n-            var beforeIsCSharp = e.BeforeContentType.IsOfType(ContentTypeNames.CSharpContentType);\n-\n-            if (afterIsCSharp == beforeIsCSharp)\n+            // It's not clear whether this situation will ever happen, but just in case.\n+            if (e.BeforeContentType == e.AfterContentType)\n             {\n                 return;\n             }\n \n-            if (afterIsCSharp)\n+            var buffer = e.Before.TextBuffer;\n+\n+            var afterIsLanguage = e.AfterContentType.IsOfType(this.ContentType.TypeName);\n+            var afterIsInteractiveCommand = e.AfterContentType.IsOfType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName);\n+            var beforeIsLanguage = e.BeforeContentType.IsOfType(this.ContentType.TypeName);\n+            var beforeIsInteractiveCommand = e.BeforeContentType.IsOfType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName);\n+\n+            Debug.Assert((afterIsLanguage && beforeIsInteractiveCommand)\n+                      || (beforeIsLanguage && afterIsInteractiveCommand));\n+\n+            // We're switching between the target language and the Interactive Command \"language\".\n+            // First, remove the current submission from the solution.\n+\n+            var oldSolution = _workspace.CurrentSolution;\n+            var newSolution = oldSolution;\n+\n+            foreach (var documentId in _workspace.GetRelatedDocumentIds(buffer.AsTextContainer()))\n             {\n-                // add a new document back to the project\n-                var project = _workspace.CurrentSolution.GetProject(_currentSubmissionProjectId);\n-                Debug.Assert(project != null);\n-                SetSubmissionDocument(buffer, project);\n+                Debug.Assert(documentId != null);\n+\n+                newSolution = newSolution.RemoveDocument(documentId);\n+\n+                // TODO (tomat): Is there a better way to remove mapping between buffer and document in REPL? \n+                // Perhaps TrackingWorkspace should implement RemoveDocumentAsync?\n+                _workspace.ClearOpenDocument(documentId);\n             }\n-            else\n-            {\n-                Debug.Assert(beforeIsCSharp);\n \n-                // remove document from the project\n-                foreach (var documentId in _workspace.GetRelatedDocumentIds(buffer.AsTextContainer()))\n-                {\n-                    Debug.Assert(documentId != null);\n-                    _workspace.SetCurrentSolution(_workspace.CurrentSolution.RemoveDocument(documentId));\n+            // Next, remove the previous submission project and update the workspace.\n+            newSolution = newSolution.RemoveProject(_currentSubmissionProjectId);\n+            _workspace.SetCurrentSolution(newSolution);\n \n-                    // TODO (tomat): Is there a better way to remove mapping between buffer and document in REPL? \n-                    // Perhaps TrackingWorkspace should implement RemoveDocumentAsync?\n-                    _workspace.ClearOpenDocument(documentId);\n+            // Add a new submission with the correct language for the current buffer.\n+            var languageName = afterIsLanguage","path":"src/Interactive/EditorFeatures/Core/Extensibility/Interactive/InteractiveEvaluator.cs","position":79,"original_position":79,"commit_id":"6d58f0c2a0f9cfb3bdf82f713106fd38b66315c2","original_commit_id":"6d58f0c2a0f9cfb3bdf82f713106fd38b66315c2","user":{"login":"DustinCampbell","id":116161,"avatar_url":"https://avatars.githubusercontent.com/u/116161?v=3","gravatar_id":"","url":"https://api.github.com/users/DustinCampbell","html_url":"https://github.com/DustinCampbell","followers_url":"https://api.github.com/users/DustinCampbell/followers","following_url":"https://api.github.com/users/DustinCampbell/following{/other_user}","gists_url":"https://api.github.com/users/DustinCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/DustinCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DustinCampbell/subscriptions","organizations_url":"https://api.github.com/users/DustinCampbell/orgs","repos_url":"https://api.github.com/users/DustinCampbell/repos","events_url":"https://api.github.com/users/DustinCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/DustinCampbell/received_events","type":"User","site_admin":false},"body":"Note that content types can have inheritance.","created_at":"2015-07-27T23:09:11Z","updated_at":"2015-07-27T23:09:11Z","html_url":"https://github.com/dotnet/roslyn/pull/4088#discussion_r35598434","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/4088","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/35598434"},"html":{"href":"https://github.com/dotnet/roslyn/pull/4088#discussion_r35598434"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/4088"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/4088","id":40721141,"html_url":"https://github.com/dotnet/roslyn/pull/4088","diff_url":"https://github.com/dotnet/roslyn/pull/4088.diff","patch_url":"https://github.com/dotnet/roslyn/pull/4088.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/4088","number":4088,"state":"open","locked":false,"title":"Fix NREs in Interactive Command completion list","user":{"login":"DustinCampbell","id":116161,"avatar_url":"https://avatars.githubusercontent.com/u/116161?v=3","gravatar_id":"","url":"https://api.github.com/users/DustinCampbell","html_url":"https://github.com/DustinCampbell","followers_url":"https://api.github.com/users/DustinCampbell/followers","following_url":"https://api.github.com/users/DustinCampbell/following{/other_user}","gists_url":"https://api.github.com/users/DustinCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/DustinCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DustinCampbell/subscriptions","organizations_url":"https://api.github.com/users/DustinCampbell/orgs","repos_url":"https://api.github.com/users/DustinCampbell/repos","events_url":"https://api.github.com/users/DustinCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/DustinCampbell/received_events","type":"User","site_admin":false},"body":"Over time, changes to the interactive window have broken the Interactive Command \"language\" such that it was no longer added to the workspace correctly. This is now fixed. Additionally, the Interactive Command's ICompletionService was located in an assembly that was not correctly MEF-imported and has been moved as part of this change.\r\n\r\nReviewers: @tmat, @amcasey, @KevinH-MS","created_at":"2015-07-23T21:34:50Z","updated_at":"2015-07-27T23:09:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a02a1f3d272c9f1d317fcfb9e4347bbcf34d01c1","assignee":{"login":"DustinCampbell","id":116161,"avatar_url":"https://avatars.githubusercontent.com/u/116161?v=3","gravatar_id":"","url":"https://api.github.com/users/DustinCampbell","html_url":"https://github.com/DustinCampbell","followers_url":"https://api.github.com/users/DustinCampbell/followers","following_url":"https://api.github.com/users/DustinCampbell/following{/other_user}","gists_url":"https://api.github.com/users/DustinCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/DustinCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DustinCampbell/subscriptions","organizations_url":"https://api.github.com/users/DustinCampbell/orgs","repos_url":"https://api.github.com/users/DustinCampbell/repos","events_url":"https://api.github.com/users/DustinCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/DustinCampbell/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/3","html_url":"https://github.com/dotnet/roslyn/milestones/1.1","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/3/labels","id":937401,"number":3,"title":"1.1","description":"This is our 1.1 Milestone.\r\n\r\n<!---\r\n@huboard:{\"order\":1.5}\r\n-->\r\n","creator":{"login":"jaredpar","id":146967,"avatar_url":"https://avatars.githubusercontent.com/u/146967?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"open_issues":398,"closed_issues":112,"state":"open","created_at":"2015-01-15T20:48:41Z","updated_at":"2015-07-27T22:59:04Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/4088/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/4088/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/4088/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/6d58f0c2a0f9cfb3bdf82f713106fd38b66315c2","head":{"label":"DustinCampbell:fix-interactive-completion","ref":"fix-interactive-completion","sha":"6d58f0c2a0f9cfb3bdf82f713106fd38b66315c2","user":{"login":"DustinCampbell","id":116161,"avatar_url":"https://avatars.githubusercontent.com/u/116161?v=3","gravatar_id":"","url":"https://api.github.com/users/DustinCampbell","html_url":"https://github.com/DustinCampbell","followers_url":"https://api.github.com/users/DustinCampbell/followers","following_url":"https://api.github.com/users/DustinCampbell/following{/other_user}","gists_url":"https://api.github.com/users/DustinCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/DustinCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DustinCampbell/subscriptions","organizations_url":"https://api.github.com/users/DustinCampbell/orgs","repos_url":"https://api.github.com/users/DustinCampbell/repos","events_url":"https://api.github.com/users/DustinCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/DustinCampbell/received_events","type":"User","site_admin":false},"repo":{"id":30651839,"name":"roslyn","full_name":"DustinCampbell/roslyn","owner":{"login":"DustinCampbell","id":116161,"avatar_url":"https://avatars.githubusercontent.com/u/116161?v=3","gravatar_id":"","url":"https://api.github.com/users/DustinCampbell","html_url":"https://github.com/DustinCampbell","followers_url":"https://api.github.com/users/DustinCampbell/followers","following_url":"https://api.github.com/users/DustinCampbell/following{/other_user}","gists_url":"https://api.github.com/users/DustinCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/DustinCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DustinCampbell/subscriptions","organizations_url":"https://api.github.com/users/DustinCampbell/orgs","repos_url":"https://api.github.com/users/DustinCampbell/repos","events_url":"https://api.github.com/users/DustinCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/DustinCampbell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DustinCampbell/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/DustinCampbell/roslyn","forks_url":"https://api.github.com/repos/DustinCampbell/roslyn/forks","keys_url":"https://api.github.com/repos/DustinCampbell/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DustinCampbell/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DustinCampbell/roslyn/teams","hooks_url":"https://api.github.com/repos/DustinCampbell/roslyn/hooks","issue_events_url":"https://api.github.com/repos/DustinCampbell/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/DustinCampbell/roslyn/events","assignees_url":"https://api.github.com/repos/DustinCampbell/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/DustinCampbell/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/DustinCampbell/roslyn/tags","blobs_url":"https://api.github.com/repos/DustinCampbell/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DustinCampbell/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DustinCampbell/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/DustinCampbell/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DustinCampbell/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/DustinCampbell/roslyn/languages","stargazers_url":"https://api.github.com/repos/DustinCampbell/roslyn/stargazers","contributors_url":"https://api.github.com/repos/DustinCampbell/roslyn/contributors","subscribers_url":"https://api.github.com/repos/DustinCampbell/roslyn/subscribers","subscription_url":"https://api.github.com/repos/DustinCampbell/roslyn/subscription","commits_url":"https://api.github.com/repos/DustinCampbell/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/DustinCampbell/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/DustinCampbell/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/DustinCampbell/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/DustinCampbell/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/DustinCampbell/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DustinCampbell/roslyn/merges","archive_url":"https://api.github.com/repos/DustinCampbell/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DustinCampbell/roslyn/downloads","issues_url":"https://api.github.com/repos/DustinCampbell/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/DustinCampbell/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/DustinCampbell/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/DustinCampbell/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DustinCampbell/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/DustinCampbell/roslyn/releases{/id}","created_at":"2015-02-11T14:36:20Z","updated_at":"2015-04-22T18:16:20Z","pushed_at":"2015-07-27T23:01:13Z","git_url":"git://github.com/DustinCampbell/roslyn.git","ssh_url":"git@github.com:DustinCampbell/roslyn.git","clone_url":"https://github.com/DustinCampbell/roslyn.git","svn_url":"https://github.com/DustinCampbell/roslyn","homepage":"","size":88496,"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":"c9320ce14b8cb4f4a50543a24480f9f96b70425c","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-07-27T21:26:39Z","pushed_at":"2015-07-27T23:06:33Z","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":155838,"stargazers_count":2848,"watchers_count":2848,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":635,"mirror_url":null,"open_issues_count":1224,"forks":635,"open_issues":1224,"watchers":2848,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/4088"},"html":{"href":"https://github.com/dotnet/roslyn/pull/4088"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/4088"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/4088/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/4088/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/4088/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/6d58f0c2a0f9cfb3bdf82f713106fd38b66315c2"}}}}