/// <summary> /// This function handles the display of the autocompletion form, create or update it /// </summary> private static void ShowSuggestionList(AutoCompletionForm form) { // we changed the list of items to display if (_needToSetItems) { DoInLock(() => { form.SetItems(CurrentItems.Cast <ListItem>().ToList()); }); _needToSetItems = false; } // only activate certain types if (_needToSetActiveTypes) { switch (CurrentActiveTypes) { case ActiveTypes.All: form.SetUnactiveType(new List <int> { (int)CompletionType.KeywordObject }); break; case ActiveTypes.KeywordObject: form.SetActiveType(new List <int> { (int)CompletionType.KeywordObject }); break; default: form.SetUnactiveType(null); break; } } // the filter uses the current caret line to know which item should be filtered, set it here int nppCurrentLine = Sci.Line.CurrentLine; CompletionFilterClass.Instance.UpdateConditions(nppCurrentLine); // filter with keyword (keyword can be empty) form.SetFilterString(_currentWord); // close if the list ends up empty after the filter if (!_openedFromShortCut && Config.Instance.AutoCompleteOnKeyInputHideIfEmpty && form.GetNbItems() == 0) { Cloak(); return; } // if the form was already visible, don't go further if (IsVisible) { return; } // update form position var lineHeight = Sci.TextHeight(nppCurrentLine); var point = Sci.GetCaretScreenLocation(); point.Y += lineHeight; form.SetPosition(point, lineHeight + 2, WinApi.GetWindowRect(Npp.CurrentSci.Handle)); form.UnCloak(); form.SetSelectedIndex(0); form.SetCaseMode(FilterCaseMode); _shownPosition = Sci.CurrentPosition; }