{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/poshtools/pulls/comments/28557439","id":28557439,"diff_hunk":"@@ -0,0 +1,104 @@\n+﻿using System.Collections.Generic;\r\n+using Microsoft.VisualStudio.Language.Intellisense;\r\n+using Microsoft.VisualStudio.Text;\r\n+using Microsoft.VisualStudio.Text.Editor;\r\n+\r\n+namespace PowerShellTools.Intellisense\r\n+{\r\n+    /// <summary>\r\n+    /// Class that is used when cycling through completions using the tab or backtab command\r\n+    /// </summary>\r\n+    internal class TabCompleteSession\r\n+    {\r\n+        private IList<Completion> _completions;\r\n+        private int _index;\r\n+        private bool _isInitialized;\r\n+\r\n+        /// <summary>\r\n+        /// Creates an uninitialized TabCompleteSession\r\n+        /// </summary>\r\n+        public TabCompleteSession()\r\n+        {\r\n+            _isInitialized = false;\r\n+        }\r\n+\r\n+        /// <summary>\r\n+        /// Creates and initializes the TabCompleteSession\r\n+        /// </summary>\r\n+        /// <param name=\"activeSession\">The active session</param>\r\n+        public TabCompleteSession(ICompletionSession activeSession)\r\n+        {\r\n+            Initialize(activeSession);\r\n+        }\r\n+\r\n+        /// <summary>\r\n+        /// Returns true if the session has been initialized, otherwise false\r\n+        /// </summary>\r\n+        public bool IsInitialized\r\n+        {\r\n+            get\r\n+            {\r\n+                return _isInitialized;\r\n+            }\r\n+        }\r\n+\r\n+        /// <summary>\r\n+        /// Initializes the TabCompleteSession with Intellisense information\r\n+        /// </summary>\r\n+        /// <param name=\"activeSession\">The active session</param>\r\n+        public void Initialize(ICompletionSession activeSession)\r\n+        {\r\n+            _completions = activeSession.SelectedCompletionSet.Completions;\r\n+            _index = _completions.IndexOf(activeSession.SelectedCompletionSet.SelectionStatus.Completion);\r\n+\r\n+            activeSession.Commit();\r\n+\r\n+            _isInitialized = true;\r\n+        }\r\n+\r\n+        /// <summary>\r\n+        /// Replaces the completion with the next completion\r\n+        /// </summary>\r\n+        /// <param name=\"textView\">The text view in which to replace the token</param>\r\n+        public void ReplaceWithNextCompletion(ITextView textView)\r\n+        {\r\n+            var newIndex = _index + 1;\r\n+\r\n+            // Wrap-around to first completion\r\n+            if (newIndex > _completions.Count - 1)\r\n+            {\r\n+                newIndex = 0;\r\n+            }\r\n+\r\n+            UpdateCompletion(textView, _index, newIndex);\r\n+        }\r\n+\r\n+        /// <summary>\r\n+        /// Replaces the completion with the previous completion\r\n+        /// </summary>\r\n+        /// <param name=\"textView\">The text view in which to replace the token</param>\r\n+        public void ReplaceWithPreviousCompletion(ITextView textView)\r\n+        {\r\n+            var newIndex = _index - 1;\r","path":"PowerShellTools/Intellisense/TabCompleteSession.cs","position":82,"original_position":82,"commit_id":"91b6776e137af6059cc01f1be3c28352ce8007ed","original_commit_id":"91b6776e137af6059cc01f1be3c28352ce8007ed","user":{"login":"EricMSFT","id":10081101,"avatar_url":"https://avatars.githubusercontent.com/u/10081101?v=3","gravatar_id":"","url":"https://api.github.com/users/EricMSFT","html_url":"https://github.com/EricMSFT","followers_url":"https://api.github.com/users/EricMSFT/followers","following_url":"https://api.github.com/users/EricMSFT/following{/other_user}","gists_url":"https://api.github.com/users/EricMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/EricMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricMSFT/subscriptions","organizations_url":"https://api.github.com/users/EricMSFT/orgs","repos_url":"https://api.github.com/users/EricMSFT/repos","events_url":"https://api.github.com/users/EricMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/EricMSFT/received_events","type":"User","site_admin":false},"body":"Just wondering, do we need worry about multi-threading here?","created_at":"2015-04-16T22:53:45Z","updated_at":"2015-04-16T22:53:45Z","html_url":"https://github.com/Microsoft/poshtools/pull/409#discussion_r28557439","pull_request_url":"https://api.github.com/repos/Microsoft/poshtools/pulls/409","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/poshtools/pulls/comments/28557439"},"html":{"href":"https://github.com/Microsoft/poshtools/pull/409#discussion_r28557439"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/poshtools/pulls/409"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/poshtools/pulls/409","id":33477506,"html_url":"https://github.com/Microsoft/poshtools/pull/409","diff_url":"https://github.com/Microsoft/poshtools/pull/409.diff","patch_url":"https://github.com/Microsoft/poshtools/pull/409.patch","issue_url":"https://api.github.com/repos/Microsoft/poshtools/issues/409","number":409,"state":"open","locked":false,"title":"Add support for cycling tab autocomplete","user":{"login":"EricJizbaMSFT","id":11282622,"avatar_url":"https://avatars.githubusercontent.com/u/11282622?v=3","gravatar_id":"","url":"https://api.github.com/users/EricJizbaMSFT","html_url":"https://github.com/EricJizbaMSFT","followers_url":"https://api.github.com/users/EricJizbaMSFT/followers","following_url":"https://api.github.com/users/EricJizbaMSFT/following{/other_user}","gists_url":"https://api.github.com/users/EricJizbaMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/EricJizbaMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricJizbaMSFT/subscriptions","organizations_url":"https://api.github.com/users/EricJizbaMSFT/orgs","repos_url":"https://api.github.com/users/EricJizbaMSFT/repos","events_url":"https://api.github.com/users/EricJizbaMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/EricJizbaMSFT/received_events","type":"User","site_admin":false},"body":"This should fix 351, 353 and adamdriscoll/14","created_at":"2015-04-16T18:10:58Z","updated_at":"2015-04-16T22:53:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"98ad5fc9c09b4914669e277aacf5f4cb7b03bbd6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/poshtools/pulls/409/commits","review_comments_url":"https://api.github.com/repos/Microsoft/poshtools/pulls/409/comments","review_comment_url":"https://api.github.com/repos/Microsoft/poshtools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/poshtools/issues/409/comments","statuses_url":"https://api.github.com/repos/Microsoft/poshtools/statuses/91b6776e137af6059cc01f1be3c28352ce8007ed","head":{"label":"Microsoft:TabComplete","ref":"TabComplete","sha":"91b6776e137af6059cc01f1be3c28352ce8007ed","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":27854486,"name":"poshtools","full_name":"Microsoft/poshtools","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/poshtools","description":"PowerShell integration for Visual Studio","fork":true,"url":"https://api.github.com/repos/Microsoft/poshtools","forks_url":"https://api.github.com/repos/Microsoft/poshtools/forks","keys_url":"https://api.github.com/repos/Microsoft/poshtools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/poshtools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/poshtools/teams","hooks_url":"https://api.github.com/repos/Microsoft/poshtools/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/poshtools/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/poshtools/events","assignees_url":"https://api.github.com/repos/Microsoft/poshtools/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/poshtools/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/poshtools/tags","blobs_url":"https://api.github.com/repos/Microsoft/poshtools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/poshtools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/poshtools/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/poshtools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/poshtools/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/poshtools/languages","stargazers_url":"https://api.github.com/repos/Microsoft/poshtools/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/poshtools/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/poshtools/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/poshtools/subscription","commits_url":"https://api.github.com/repos/Microsoft/poshtools/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/poshtools/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/poshtools/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/poshtools/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/poshtools/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/poshtools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/poshtools/merges","archive_url":"https://api.github.com/repos/Microsoft/poshtools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/poshtools/downloads","issues_url":"https://api.github.com/repos/Microsoft/poshtools/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/poshtools/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/poshtools/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/poshtools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/poshtools/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/poshtools/releases{/id}","created_at":"2014-12-11T04:44:03Z","updated_at":"2015-04-16T21:00:33Z","pushed_at":"2015-04-16T22:34:27Z","git_url":"git://github.com/Microsoft/poshtools.git","ssh_url":"git@github.com:Microsoft/poshtools.git","clone_url":"https://github.com/Microsoft/poshtools.git","svn_url":"https://github.com/Microsoft/poshtools","homepage":"http://www.visualstudio.com/","size":12526,"stargazers_count":76,"watchers_count":76,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":103,"forks":10,"open_issues":103,"watchers":76,"default_branch":"dev"}},"base":{"label":"Microsoft:dev","ref":"dev","sha":"2e0f952a7e60b5648e93e5a05c33eba5eeee258d","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":27854486,"name":"poshtools","full_name":"Microsoft/poshtools","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/poshtools","description":"PowerShell integration for Visual Studio","fork":true,"url":"https://api.github.com/repos/Microsoft/poshtools","forks_url":"https://api.github.com/repos/Microsoft/poshtools/forks","keys_url":"https://api.github.com/repos/Microsoft/poshtools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/poshtools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/poshtools/teams","hooks_url":"https://api.github.com/repos/Microsoft/poshtools/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/poshtools/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/poshtools/events","assignees_url":"https://api.github.com/repos/Microsoft/poshtools/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/poshtools/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/poshtools/tags","blobs_url":"https://api.github.com/repos/Microsoft/poshtools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/poshtools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/poshtools/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/poshtools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/poshtools/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/poshtools/languages","stargazers_url":"https://api.github.com/repos/Microsoft/poshtools/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/poshtools/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/poshtools/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/poshtools/subscription","commits_url":"https://api.github.com/repos/Microsoft/poshtools/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/poshtools/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/poshtools/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/poshtools/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/poshtools/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/poshtools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/poshtools/merges","archive_url":"https://api.github.com/repos/Microsoft/poshtools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/poshtools/downloads","issues_url":"https://api.github.com/repos/Microsoft/poshtools/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/poshtools/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/poshtools/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/poshtools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/poshtools/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/poshtools/releases{/id}","created_at":"2014-12-11T04:44:03Z","updated_at":"2015-04-16T21:00:33Z","pushed_at":"2015-04-16T22:34:27Z","git_url":"git://github.com/Microsoft/poshtools.git","ssh_url":"git@github.com:Microsoft/poshtools.git","clone_url":"https://github.com/Microsoft/poshtools.git","svn_url":"https://github.com/Microsoft/poshtools","homepage":"http://www.visualstudio.com/","size":12526,"stargazers_count":76,"watchers_count":76,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":103,"forks":10,"open_issues":103,"watchers":76,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/poshtools/pulls/409"},"html":{"href":"https://github.com/Microsoft/poshtools/pull/409"},"issue":{"href":"https://api.github.com/repos/Microsoft/poshtools/issues/409"},"comments":{"href":"https://api.github.com/repos/Microsoft/poshtools/issues/409/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/poshtools/pulls/409/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/poshtools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/poshtools/pulls/409/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/poshtools/statuses/91b6776e137af6059cc01f1be3c28352ce8007ed"}}}}