From ec5716c43605d3f8a68b60c41358494c822d157d Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 16 Jun 2016 02:59:31 +0100 Subject: [PATCH] Fix #730 #766 --- Plugins/Wox.Plugin.Folder/Main.cs | 31 ++++++++++++--------------- Plugins/Wox.Plugin.Folder/Settings.cs | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Plugins/Wox.Plugin.Folder/Main.cs b/Plugins/Wox.Plugin.Folder/Main.cs index bde958bf38..e8f33a951b 100644 --- a/Plugins/Wox.Plugin.Folder/Main.cs +++ b/Plugins/Wox.Plugin.Folder/Main.cs @@ -11,8 +11,8 @@ namespace Wox.Plugin.Folder { public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable { - private static List driverNames; - private PluginInitContext context; + private static List _driverNames; + private PluginInitContext _context; private readonly Settings _settings; private readonly PluginJsonStorage _storage; @@ -21,6 +21,7 @@ namespace Wox.Plugin.Folder { _storage = new PluginJsonStorage(); _settings = _storage.Load(); + InitialDriverList(); } public void Save() @@ -30,17 +31,13 @@ namespace Wox.Plugin.Folder public Control CreateSettingPanel() { - return new FileSystemSettings(context.API, _settings); + return new FileSystemSettings(_context.API, _settings); } public void Init(PluginInitContext context) { - this.context = context; - InitialDriverList(); - if (_settings.FolderLinks == null) - { - _settings.FolderLinks = new List(); - } + _context = context; + } public List Query(Query query) @@ -71,13 +68,13 @@ namespace Wox.Plugin.Folder return false; } } - context.API.ChangeQuery($"{query.ActionKeyword} {item.Path}{(item.Path.EndsWith("\\") ? "" : "\\")}"); + _context.API.ChangeQuery($"{query.ActionKeyword} {item.Path}{(item.Path.EndsWith("\\") ? "" : "\\")}"); return false; }, ContextData = item, }).ToList(); - if (driverNames != null && !driverNames.Any(search.StartsWith)) + if (_driverNames != null && !_driverNames.Any(search.StartsWith)) return results; //if (!input.EndsWith("\\")) @@ -97,13 +94,13 @@ namespace Wox.Plugin.Folder } private void InitialDriverList() { - if (driverNames == null) + if (_driverNames == null) { - driverNames = new List(); + _driverNames = new List(); DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo driver in allDrives) { - driverNames.Add(driver.Name.ToLower().TrimEnd('\\')); + _driverNames.Add(driver.Name.ToLower().TrimEnd('\\')); } } } @@ -180,7 +177,7 @@ namespace Wox.Plugin.Folder return false; } } - context.API.ChangeQuery($"{query.ActionKeyword} {dirCopy.FullName}\\"); + _context.API.ChangeQuery($"{query.ActionKeyword} {dirCopy.FullName}\\"); return false; } }; @@ -223,12 +220,12 @@ namespace Wox.Plugin.Folder public string GetTranslatedPluginTitle() { - return context.API.GetTranslation("wox_plugin_folder_plugin_name"); + return _context.API.GetTranslation("wox_plugin_folder_plugin_name"); } public string GetTranslatedPluginDescription() { - return context.API.GetTranslation("wox_plugin_folder_plugin_description"); + return _context.API.GetTranslation("wox_plugin_folder_plugin_description"); } } } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/Settings.cs b/Plugins/Wox.Plugin.Folder/Settings.cs index 5c29c0c39f..27518258f9 100644 --- a/Plugins/Wox.Plugin.Folder/Settings.cs +++ b/Plugins/Wox.Plugin.Folder/Settings.cs @@ -7,6 +7,6 @@ namespace Wox.Plugin.Folder public class Settings { [JsonProperty] - public List FolderLinks { get; set; } + public List FolderLinks { get; set; } = new List(); } }