-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Powertoys Run | VSCodeWorkspaces- add support for vscode 1.64 - bug fix #15247 #15259
Changes from all commits
3f64c77
c18feec
b77b541
d3d2a35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,109 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
<Import Project="..\..\..\..\Version.props" /> | ||
<Import Project="..\..\..\..\Version.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<ProjectGuid>{4D971245-7A70-41D5-BAA0-DDB5684CAF51}</ProjectGuid> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Community.PowerToys.Run.Plugin.VSCodeWorkspaces</RootNamespace> | ||
<AssemblyName>Community.PowerToys.Run.Plugin.VSCodeWorkspaces</AssemblyName> | ||
<Version>$(Version).0</Version> | ||
<useWPF>true</useWPF> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<Platforms>x64</Platforms> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<ProjectGuid>{4D971245-7A70-41D5-BAA0-DDB5684CAF51}</ProjectGuid> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Community.PowerToys.Run.Plugin.VSCodeWorkspaces</RootNamespace> | ||
<AssemblyName>Community.PowerToys.Run.Plugin.VSCodeWorkspaces</AssemblyName> | ||
<Version>$(Version).0</Version> | ||
<useWPF>true</useWPF> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<Platforms>x64</Platforms> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\VSCodeWorkspaces\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<WarningLevel>4</WarningLevel> | ||
<Optimize>false</Optimize> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\VSCodeWorkspaces\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<WarningLevel>4</WarningLevel> | ||
<Optimize>false</Optimize> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\VSCodeWorkspaces\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<WarningLevel>4</WarningLevel> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="plugin.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj" /> | ||
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs"> | ||
<Link>GlobalSuppressions.cs</Link> | ||
</Compile> | ||
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json"> | ||
<Link>StyleCop.json</Link> | ||
</AdditionalFiles> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.Runtime" Version="4.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Windows.Foundation.UniversalApiContract"> | ||
<HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Foundation.UniversalApiContract\8.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Images\folder.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Images\monitor.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Images\code-dark.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Images\code-light.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\VSCodeWorkspaces\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<WarningLevel>4</WarningLevel> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="plugin.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj" /> | ||
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs"> | ||
<Link>GlobalSuppressions.cs</Link> | ||
</Compile> | ||
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json"> | ||
<Link>StyleCop.json</Link> | ||
</AdditionalFiles> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" /> | ||
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.1" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.Runtime" Version="4.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Windows.Foundation.UniversalApiContract"> | ||
<HintPath>C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Foundation.UniversalApiContract\8.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Images\folder.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Images\monitor.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Images\code-dark.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Images\code-light.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper | ||
{ | ||
// v1.64 uses AppData\Roaming\Code\User\globalStorage\state.vscdb - history.recentlyOpenedPathsList | ||
public class VSCodeStorageEntries | ||
{ | ||
[JsonPropertyName("entries")] | ||
public List<VSCodeWorkspaceEntry> Entries { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System.Linq; | ||
using System.Text.Json; | ||
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper; | ||
using Microsoft.Data.Sqlite; | ||
using Wox.Plugin.Logger; | ||
|
||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper | ||
|
@@ -18,7 +19,7 @@ public VSCodeWorkspacesApi() | |
{ | ||
} | ||
|
||
private VSCodeWorkspace ParseVSCodeUri(string uri, VSCodeInstance vscodeInstance, bool isWorkspaceFile = false) | ||
private VSCodeWorkspace ParseVSCodeUri(string uri, VSCodeInstance vscodeInstance, bool isWorkspace = false) | ||
{ | ||
if (uri != null && uri is string) | ||
{ | ||
|
@@ -38,7 +39,7 @@ private VSCodeWorkspace ParseVSCodeUri(string uri, VSCodeInstance vscodeInstance | |
return new VSCodeWorkspace() | ||
{ | ||
Path = uri, | ||
WorkspaceType = isWorkspaceFile ? WorkspaceType.WorkspaceFile : WorkspaceType.ProjectFolder, | ||
WorkspaceType = isWorkspace ? WorkspaceType.WorkspaceFile : WorkspaceType.ProjectFolder, | ||
RelativePath = typeWorkspace.Path, | ||
FolderName = folderName, | ||
ExtraInfo = typeWorkspace.MachineName, | ||
|
@@ -62,6 +63,9 @@ public List<VSCodeWorkspace> Workspaces | |
// storage.json contains opened Workspaces | ||
var vscode_storage = Path.Combine(vscodeInstance.AppData, "storage.json"); | ||
|
||
// User/globalStorage/state.vscdb - history.recentlyOpenedPathsList - vscode v1.64 or later | ||
var vscode_storage_db = Path.Combine(vscodeInstance.AppData, "User/globalStorage/state.vscdb"); | ||
|
||
if (File.Exists(vscode_storage)) | ||
{ | ||
var fileContent = File.ReadAllText(vscode_storage); | ||
|
@@ -70,7 +74,7 @@ public List<VSCodeWorkspace> Workspaces | |
{ | ||
VSCodeStorageFile vscodeStorageFile = JsonSerializer.Deserialize<VSCodeStorageFile>(fileContent); | ||
|
||
if (vscodeStorageFile != null) | ||
if (vscodeStorageFile != null && vscodeStorageFile.OpenedPathsList != null) | ||
{ | ||
// for previous versions of vscode | ||
if (vscodeStorageFile.OpenedPathsList.Workspaces3 != null) | ||
|
@@ -106,6 +110,50 @@ public List<VSCodeWorkspace> Workspaces | |
} | ||
} | ||
} | ||
else if (File.Exists(vscode_storage_db)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we can't read workspaces if there's no vscode_storage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
{ | ||
var sqliteConnection = new SqliteConnection($"Data Source={vscode_storage_db};Mode=ReadOnly;"); | ||
sqliteConnection.Open(); | ||
|
||
if (sqliteConnection.State == System.Data.ConnectionState.Open) | ||
{ | ||
var sqlite_cmd = sqliteConnection.CreateCommand(); | ||
sqlite_cmd.CommandText = "SELECT value FROM ItemTable WHERE key LIKE 'history.recentlyOpenedPathsList'"; | ||
|
||
var sqlite_datareader = sqlite_cmd.ExecuteReader(); | ||
|
||
if (sqlite_datareader.Read()) | ||
{ | ||
string entries = sqlite_datareader.GetString(0); | ||
if (!string.IsNullOrEmpty(entries)) | ||
{ | ||
VSCodeStorageEntries vscodeStorageEntries = JsonSerializer.Deserialize<VSCodeStorageEntries>(entries); | ||
if (vscodeStorageEntries.Entries != null) | ||
{ | ||
vscodeStorageEntries.Entries = vscodeStorageEntries.Entries.Where(x => x != null).ToList(); | ||
foreach (var entry in vscodeStorageEntries.Entries) | ||
{ | ||
bool isWorkspaceFile = false; | ||
var uri = entry.FolderUri; | ||
if (entry.Workspace != null && entry.Workspace.ConfigPath != null) | ||
{ | ||
isWorkspaceFile = true; | ||
uri = entry.Workspace.ConfigPath; | ||
} | ||
|
||
var workspace = ParseVSCodeUri(uri, vscodeInstance, isWorkspaceFile); | ||
if (workspace != null) | ||
{ | ||
results.Add(workspace); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
sqliteConnection.Close(); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When VS Code v1.64 is out and installed locally (updated current version) this file will still exist & contain
OpenedPathsList
? In that case new workspaces stored in new file won't be picked up?Also, on VS Code update, will workspaces from old storage.json file be copied to new file or not ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the storage.json file will exist but the OpenedPathsList will not.
When vscode updates the workspaces from the storage.json will be moved to Backup/workspaces.json by vscode as far as i know.