mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Merge branch 'master' into spelling
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -19,6 +19,8 @@ namespace Microsoft.Plugin.Indexer
|
||||
{
|
||||
internal class ContextMenuLoader : IContextMenu
|
||||
{
|
||||
private readonly IPath _path = new FileSystem().Path;
|
||||
|
||||
private readonly PluginInitContext _context;
|
||||
|
||||
public enum ResultType
|
||||
@@ -41,7 +43,7 @@ namespace Microsoft.Plugin.Indexer
|
||||
var contextMenus = new List<ContextMenuResult>();
|
||||
if (selectedResult.ContextData is SearchResult record)
|
||||
{
|
||||
ResultType type = Path.HasExtension(record.Path) ? ResultType.File : ResultType.Folder;
|
||||
ResultType type = _path.HasExtension(record.Path) ? ResultType.File : ResultType.Folder;
|
||||
|
||||
if (type == ResultType.File)
|
||||
{
|
||||
@@ -95,7 +97,7 @@ namespace Microsoft.Plugin.Indexer
|
||||
{
|
||||
if (type == ResultType.File)
|
||||
{
|
||||
Helper.OpenInConsole(Path.GetDirectoryName(record.Path));
|
||||
Helper.OpenInConsole(_path.GetDirectoryName(record.Path));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -147,9 +149,10 @@ namespace Microsoft.Plugin.Indexer
|
||||
// Function to test if the file can be run as admin
|
||||
private bool CanFileBeRunAsAdmin(string path)
|
||||
{
|
||||
string fileExtension = Path.GetExtension(path);
|
||||
string fileExtension = _path.GetExtension(path);
|
||||
foreach (string extension in appExtensions)
|
||||
{
|
||||
// Using OrdinalIgnoreCase since this is internal
|
||||
if (extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
@@ -24,6 +24,8 @@ namespace Microsoft.Plugin.Indexer
|
||||
{
|
||||
internal class Main : ISettingProvider, IPlugin, ISavable, IPluginI18n, IContextMenu, IDisposable, IDelayedExecutionPlugin
|
||||
{
|
||||
private static readonly IFileSystem _fileSystem = new FileSystem();
|
||||
|
||||
// This variable contains metadata about the Plugin
|
||||
private PluginInitContext _context;
|
||||
|
||||
@@ -38,7 +40,7 @@ namespace Microsoft.Plugin.Indexer
|
||||
private readonly WindowsSearchAPI _api = new WindowsSearchAPI(_search);
|
||||
|
||||
// To obtain information regarding the drives that are indexed
|
||||
private readonly IndexerDriveDetection _driveDetection = new IndexerDriveDetection(new RegistryWrapper(), new DriveInfoWrapper());
|
||||
private readonly IndexerDriveDetection _driveDetection = new IndexerDriveDetection(new RegistryWrapper(), new DriveDetection.DriveInfoWrapper());
|
||||
|
||||
// Reserved keywords in oleDB
|
||||
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$";
|
||||
@@ -110,12 +112,14 @@ namespace Microsoft.Plugin.Indexer
|
||||
foreach (var searchResult in searchResultsList)
|
||||
{
|
||||
var path = searchResult.Path;
|
||||
|
||||
// Using CurrentCulture since this is user facing
|
||||
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0} : {1}", Properties.Resources.Microsoft_plugin_indexer_name, searchResult.Title);
|
||||
var toolTipText = string.Format(CultureInfo.CurrentCulture, "{0} : {1}", Properties.Resources.Microsoft_plugin_indexer_path, path);
|
||||
string workingDir = null;
|
||||
if (_settings.UseLocationAsWorkingDir)
|
||||
{
|
||||
workingDir = Path.GetDirectoryName(path);
|
||||
workingDir = _fileSystem.Path.GetDirectoryName(path);
|
||||
}
|
||||
|
||||
Result r = new Result();
|
||||
@@ -149,7 +153,7 @@ namespace Microsoft.Plugin.Indexer
|
||||
r.ContextData = searchResult;
|
||||
|
||||
// If the result is a directory, then it's display should show a directory.
|
||||
if (Directory.Exists(path))
|
||||
if (_fileSystem.Directory.Exists(path))
|
||||
{
|
||||
r.QueryTextDisplay = path;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
|
||||
}
|
||||
|
||||
// # is URI syntax for the fragment component, need to be encoded so LocalPath returns complete path
|
||||
// Using OrdinalIgnoreCase since this is internal and used with symbols
|
||||
var string_path = ((string)oleDBResult.FieldData[0]).Replace("#", "%23", StringComparison.OrdinalIgnoreCase);
|
||||
var uri_path = new Uri(string_path);
|
||||
|
||||
@@ -89,10 +90,11 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
|
||||
// convert file pattern if it is not '*'. Don't create restriction for '*' as it includes all files.
|
||||
if (pattern != "*")
|
||||
{
|
||||
pattern = pattern.Replace("*", "%", StringComparison.InvariantCulture);
|
||||
pattern = pattern.Replace("?", "_", StringComparison.InvariantCulture);
|
||||
// Using Ordinal since these are internal and used with symbols
|
||||
pattern = pattern.Replace("*", "%", StringComparison.Ordinal);
|
||||
pattern = pattern.Replace("?", "_", StringComparison.Ordinal);
|
||||
|
||||
if (pattern.Contains("%", StringComparison.InvariantCulture) || pattern.Contains("_", StringComparison.InvariantCulture))
|
||||
if (pattern.Contains("%", StringComparison.Ordinal) || pattern.Contains("_", StringComparison.Ordinal))
|
||||
{
|
||||
queryHelper.QueryWhereRestrictions += " AND System.FileName LIKE '" + pattern + "' ";
|
||||
}
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Upozornění: Ne všechny jednotky jsou indexované.]]></Val>
|
||||
<Val><![CDATA[Upozornění: Ne všechny soubory jsou indexované.]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Warnung: Nicht alle Laufwerke sind indiziert.]]></Val>
|
||||
<Val><![CDATA[Warnung: Nicht alle Dateien sind indiziert.]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Advertencia: No se indexaron todas las unidades.]]></Val>
|
||||
<Val><![CDATA[Advertencia: No se indexaron todos los archivos.]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[警告: すべてのドライブがインデックス化されているわけではありません。]]></Val>
|
||||
<Val><![CDATA[警告: すべてのファイルがインデックス化されているわけではありません。]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Waarschuwing: niet alle stations zijn geïndexeerd.]]></Val>
|
||||
<Val><![CDATA[Waarschuwing: niet alle bestanden zijn geïndexeerd.]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Ostrzeżenie: Nie wszystkie dyski są indeksowane.]]></Val>
|
||||
<Val><![CDATA[Ostrzeżenie: Nie wszystkie pliki są indeksowane.]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Внимание! Проиндексированы не все диски.]]></Val>
|
||||
<Val><![CDATA[Предупреждение: индексируются не все файлы.]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
</Item>
|
||||
<Item ItemId=";Microsoft_plugin_indexer_drivedetectionwarning" ItemType="0;.resx" PsrId="211" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
<Val><![CDATA[Warning: Not all files are indexed.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[警告: 並非所有磁碟機皆已編製索引。]]></Val>
|
||||
<Val><![CDATA[警告: 並非所有檔案皆已編製索引。]]></Val>
|
||||
</Tgt>
|
||||
<Prev Cat="Text">
|
||||
<Val><![CDATA[Warning: Not all drives are indexed.]]></Val>
|
||||
</Prev>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
|
||||
Reference in New Issue
Block a user