From 16d6a8ae5f57deee3427f3614519351ddea73548 Mon Sep 17 00:00:00 2001 From: Ehsan Iran-Nejad Date: Mon, 17 Apr 2017 18:43:10 -0700 Subject: [PATCH] Better code completion list Works correctly on python classes derivded from "object" mixes lower and upper attributes together sorted by name pushes all reserved names to the end of the list --- PythonConsoleControl/PythonConsoleCompletionDataProvider.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PythonConsoleControl/PythonConsoleCompletionDataProvider.cs b/PythonConsoleControl/PythonConsoleCompletionDataProvider.cs index 20069fd..595e825 100644 --- a/PythonConsoleControl/PythonConsoleCompletionDataProvider.cs +++ b/PythonConsoleControl/PythonConsoleCompletionDataProvider.cs @@ -57,13 +57,14 @@ public ICompletionData[] GenerateCompletionData(string line) //IList members = commandLine.ScriptScope.Engine.Operations.GetMemberNames(value); Type type = TryGetType(name); // Use Reflection for everything except in-built Python types and COM pbjects. - if (type != null && type.Namespace != "IronPython.Runtime" && (type.Name != "__ComObject")) + if (type != null && type.Namespace != "IronPython.Runtime" && !type.FullName.Contains("IronPython.NewTypes") && (type.Name != "__ComObject")) { PopulateFromCLRType(items, type, name); } else { - string dirCommand = "dir(" + name + ")"; + //string dirCommand = "dir(" + name + ")"; + string dirCommand = "sorted([m for m in dir(" + name + ") if not m.startswith('__')], key = str.lower) + sorted([m for m in dir(" + name + ") if m.startswith('__')])"; object value = commandLine.ScriptScope.Engine.CreateScriptSourceFromString(dirCommand, SourceCodeKind.Expression).Execute(commandLine.ScriptScope); AutocompletionInProgress = false; foreach (object member in (value as IronPython.Runtime.List))