mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 19:19:23 +08:00
Solving issues from last commit
This commit is contained in:
parent
81467a86cc
commit
841e90dc46
@ -88,7 +88,7 @@ namespace Python.Runtime {
|
||||
PyTrue = Runtime.PyObject_GetAttrString(op, "True");
|
||||
PyFalse = Runtime.PyObject_GetAttrString(op, "False");
|
||||
|
||||
PyBoolType = Runtime.PyObject_Type(PyTrue);> Python.Runtime.Runtime.Initialize() C#
|
||||
PyBoolType = Runtime.PyObject_Type(PyTrue);
|
||||
|
||||
PyNoneType = Runtime.PyObject_Type(PyNone);
|
||||
PyTypeType = Runtime.PyObject_Type(PyNoneType);
|
||||
@ -1071,25 +1071,21 @@ namespace Python.Runtime {
|
||||
public unsafe static extern IntPtr
|
||||
PyUnicode_FromOrdinal(int c);
|
||||
|
||||
public static IntPtr PyUnicode_FromString(string s)
|
||||
{
|
||||
public static IntPtr PyUnicode_FromString(string s) {
|
||||
return PyUnicode_FromUnicode(s, (s.Length));
|
||||
}
|
||||
|
||||
public unsafe static string GetManagedString(IntPtr op)
|
||||
{
|
||||
public unsafe static string GetManagedString(IntPtr op) {
|
||||
IntPtr type = PyObject_TYPE(op);
|
||||
|
||||
if (type == Runtime.PyStringType)
|
||||
{
|
||||
if (type == Runtime.PyStringType) {
|
||||
return Marshal.PtrToStringAnsi(
|
||||
PyString_AS_STRING(op),
|
||||
Runtime.PyString_Size(op)
|
||||
);
|
||||
}
|
||||
|
||||
if (type == Runtime.PyUnicodeType)
|
||||
{
|
||||
if (type == Runtime.PyUnicodeType) {
|
||||
char* p = Runtime.PyUnicode_AsUnicode(op);
|
||||
int size = Runtime.PyUnicode_GetSize(op);
|
||||
return new String(p, 0, size);
|
||||
|
@ -40,35 +40,28 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
||||
#endregion Misc
|
||||
|
||||
protected override List<Result> QueryInternal(Query query) {
|
||||
|
||||
#region 1
|
||||
var results = new List<Result>();
|
||||
var input = query.RawQuery.ToLower();
|
||||
var inputName = input.Split(new string[] { @"\" }, StringSplitOptions.None).First().ToLower();
|
||||
var link = UserSettingStorage.Instance.FolderLinks.FirstOrDefault(x => x.Nickname.Equals(inputName, StringComparison.OrdinalIgnoreCase));
|
||||
var currentPath = link == null ? input : link.Path + input.Remove(0, inputName.Length);
|
||||
InitialDriverList();
|
||||
|
||||
//TODO: Consider always clearing the cache
|
||||
List<Result> results = new List<Result>();
|
||||
//TODO: Prove the following was not ever actually used
|
||||
//if (string.IsNullOrEmpty(query.RawQuery)) {
|
||||
// // clear the cache
|
||||
// if (parentDirectories.Count > 0) parentDirectories.Clear();
|
||||
// return results;
|
||||
//}
|
||||
|
||||
#endregion 1
|
||||
|
||||
var input = query.RawQuery.ToLower();
|
||||
var inputName = input.Split(new string[] { @"\" }, StringSplitOptions.None).First().ToLower();
|
||||
var link = UserSettingStorage.Instance.FolderLinks.FirstOrDefault(x => x.Nickname.Equals(inputName, StringComparison.OrdinalIgnoreCase));
|
||||
var currentPath = link == null ? input : link.Path + input.Remove(0, inputName.Length);
|
||||
|
||||
InitialDriverList();
|
||||
|
||||
foreach (var item in UserSettingStorage.Instance.FolderLinks.Where(x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase))) {
|
||||
//if (item.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)) { //&& item.Nickname.Length != input.Length) {
|
||||
results.Add(new Result(item.Nickname, "Images/folder.png") {
|
||||
Action = (c) => {
|
||||
context.ChangeQuery(item.Nickname);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
//}
|
||||
}
|
||||
|
||||
if (link == null && !driverNames.Any(input.StartsWith))
|
||||
@ -77,46 +70,6 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
||||
QueryInternal_Directory_Exists(currentPath, input, results);
|
||||
|
||||
return results;
|
||||
|
||||
/*
|
||||
// change to search in current directory
|
||||
string parentDir = null;
|
||||
try {
|
||||
parentDir = Path.GetDirectoryName(input);
|
||||
}
|
||||
catch { }
|
||||
|
||||
|
||||
|
||||
|
||||
return results;
|
||||
if (!string.IsNullOrEmpty(parentDir) && results.Count == 0) {
|
||||
parentDir = parentDir.TrimEnd('\\', '/');
|
||||
//TODO: Why are we doing the following check
|
||||
|
||||
//FUCK THIS CODE o.O!!!!!!!
|
||||
|
||||
if (parentDirectories.ContainsKey(parentDir)) {
|
||||
var fuzzy = FuzzyMatcher.Create(Path.GetFileName(currentPath).ToLower());
|
||||
foreach (var dir in parentDirectories[parentDir]) {
|
||||
if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
||||
|
||||
var matchResult = fuzzy.Evaluate(dir.Name);
|
||||
if (!matchResult.Success) continue;
|
||||
|
||||
results.Add(new Result(dir.Name, "Images/folder.png") {
|
||||
Score = matchResult.Score,
|
||||
Action = (c) => {
|
||||
context.ChangeQuery(dir.FullName);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
*/
|
||||
}
|
||||
|
||||
private void InitialDriverList() {
|
||||
@ -157,30 +110,11 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
||||
|
||||
results.Add(result);
|
||||
}
|
||||
|
||||
//if (results.Count == 0) {
|
||||
// results.Add(new Result("Open this directory", "Images/folder.png", "No files in this directory") {
|
||||
// Action = (c) => {
|
||||
// Process.Start(currentPath);
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
}
|
||||
else {
|
||||
//results.Add(new Result("Open this directory", "Images/folder.png", string.Format("path: {0}", currentPath)) {
|
||||
// Score = 50,
|
||||
// Action = (c) => {
|
||||
// Process.Start(currentPath);
|
||||
// return true;
|
||||
// }
|
||||
//});
|
||||
//TODO: Make sure we do not need anything here
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
/**************************************************************/
|
||||
|
||||
if (results.Count == 0) {
|
||||
results.Add(new Result("Open this directory", "Images/folder.png", "No files in this directory") {
|
||||
Action = (c) => {
|
||||
@ -190,12 +124,6 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
/**************************************************************/
|
||||
|
||||
var Folder = Path.GetDirectoryName(currentPath);
|
||||
if (Folder != null) {
|
||||
var dirInfo1 = new DirectoryInfo(Folder);
|
||||
|
@ -33,7 +33,7 @@
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
|
Loading…
Reference in New Issue
Block a user