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
File diff suppressed because it is too large
Load Diff
@ -40,35 +40,28 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
|||||||
#endregion Misc
|
#endregion Misc
|
||||||
|
|
||||||
protected override List<Result> QueryInternal(Query query) {
|
protected override List<Result> QueryInternal(Query query) {
|
||||||
|
var results = new List<Result>();
|
||||||
#region 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();
|
||||||
|
|
||||||
//TODO: Consider always clearing the cache
|
//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)) {
|
//if (string.IsNullOrEmpty(query.RawQuery)) {
|
||||||
// // clear the cache
|
// // clear the cache
|
||||||
// if (parentDirectories.Count > 0) parentDirectories.Clear();
|
// if (parentDirectories.Count > 0) parentDirectories.Clear();
|
||||||
// return results;
|
// 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))) {
|
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") {
|
results.Add(new Result(item.Nickname, "Images/folder.png") {
|
||||||
Action = (c) => {
|
Action = (c) => {
|
||||||
context.ChangeQuery(item.Nickname);
|
context.ChangeQuery(item.Nickname);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link == null && !driverNames.Any(input.StartsWith))
|
if (link == null && !driverNames.Any(input.StartsWith))
|
||||||
@ -77,46 +70,6 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
|||||||
QueryInternal_Directory_Exists(currentPath, input, results);
|
QueryInternal_Directory_Exists(currentPath, input, results);
|
||||||
|
|
||||||
return 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() {
|
private void InitialDriverList() {
|
||||||
@ -157,30 +110,11 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
|||||||
|
|
||||||
results.Add(result);
|
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 {
|
else {
|
||||||
//results.Add(new Result("Open this directory", "Images/folder.png", string.Format("path: {0}", currentPath)) {
|
//TODO: Make sure we do not need anything here
|
||||||
// Score = 50,
|
|
||||||
// Action = (c) => {
|
|
||||||
// Process.Start(currentPath);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
if (results.Count == 0) {
|
if (results.Count == 0) {
|
||||||
results.Add(new Result("Open this directory", "Images/folder.png", "No files in this directory") {
|
results.Add(new Result("Open this directory", "Images/folder.png", "No files in this directory") {
|
||||||
Action = (c) => {
|
Action = (c) => {
|
||||||
@ -190,12 +124,6 @@ namespace Wox.Plugin.SystemPlugins.FileSystem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
var Folder = Path.GetDirectoryName(currentPath);
|
var Folder = Path.GetDirectoryName(currentPath);
|
||||||
if (Folder != null) {
|
if (Folder != null) {
|
||||||
var dirInfo1 = new DirectoryInfo(Folder);
|
var dirInfo1 = new DirectoryInfo(Folder);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
|
Loading…
Reference in New Issue
Block a user