Esempio n. 1
0
        private void OffsetCompletionSelection(int offset)
        {
            if (this.activeSession == null)
            {
                return;
            }
            int count = this.activeSession.Completions.Count;

            if (count == 1)
            {
                this.activeSession.SetSelectionStatus(this.activeSession.Completions[0], CompletionSelectionOptions.Selected | CompletionSelectionOptions.Unique);
            }
            else
            {
                int num   = this.activeSession.Completions.IndexOf(this.activeSession.SelectionStatus.SelectedCompletion);
                int index = num + offset;
                if (index < 0)
                {
                    index = 0;
                }
                else if (index >= count)
                {
                    index = count - 1;
                }
                if (index == num && !CompletionSessionExtensions.IsHollowSelected(this.activeSession.SelectionStatus))
                {
                    return;
                }
                if (CompletionSessionExtensions.IsHollowSelected(this.activeSession.SelectionStatus))
                {
                    index = num;
                }
                this.activeSession.SetSelectionStatus(this.activeSession.Completions[index], CompletionSelectionOptions.Selected | CompletionSelectionOptions.Unique);
            }
        }
Esempio n. 2
0
        private void ActiveSession_Committed(object sender, EventArgs e)
        {
            ICompletionSession completionSession = sender as ICompletionSession;

            if (completionSession != null && CompletionSessionExtensions.IsSelected(completionSession.SelectionStatus))
            {
                ICodeAidCompletion codeAidCompletion = completionSession.SelectionStatus.SelectedCompletion as ICodeAidCompletion;
                if (codeAidCompletion != null)
                {
                    int  completionCaretDelta = codeAidCompletion.CompletionCaretDelta;
                    bool flag = completionCaretDelta > 0;
                    int  num  = Math.Abs(completionCaretDelta);
                    for (int index = 0; index < num; ++index)
                    {
                        if (flag)
                        {
                            this.editorOperations.MoveToNextCharacter(false);
                        }
                        else
                        {
                            this.editorOperations.MoveToPreviousCharacter(false);
                        }
                    }
                }
            }
            this.OnActiveSessionClosed();
        }
Esempio n. 3
0
 private void CommitCompletionSession(bool shouldCommitHollowSelections)
 {
     if (this.activeSession == null || !CompletionSessionExtensions.IsSelected(this.activeSession.SelectionStatus) && (!shouldCommitHollowSelections || !CompletionSessionExtensions.IsHollowSelected(this.activeSession.SelectionStatus)))
     {
         return;
     }
     this.activeSession.Commit();
     this.textView.Selection.Clear();
     this.textView.Caret.EnsureVisible();
 }
Esempio n. 4
0
        private CodeAidContext CreateCodeAidContext()
        {
            ITextSnapshot             currentSnapshot = this.textView.TextBuffer.CurrentSnapshot;
            CompletionSelectionStatus status          = this.activeSession != null ? this.activeSession.SelectionStatus : (CompletionSelectionStatus)null;
            ICompletion completion1 = status == null || !CompletionSessionExtensions.IsSelected(status) ? (ICompletion)null : this.activeSession.SelectionStatus.SelectedCompletion;
            ICompletion completion2 = status == null || !CompletionSessionExtensions.IsHollowSelected(status) ? (ICompletion)null : this.activeSession.SelectionStatus.SelectedCompletion;
            int         position    = this.LeftmostTextViewSelection();

            return(new CodeAidContext()
            {
                CurrentPosition = new SnapshotPoint(currentSnapshot, position),
                SelectionSpan = this.textView.Selection.SelectionSpan,
                SessionStartingPosition = this.activeSessionStartPoint,
                SessionSelectedCompletion = completion1,
                SessionHollowSelectedCompletion = completion2
            });
        }