Skip to content
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

Merged
merged 4 commits into from
Jan 18, 2022

Conversation

ricardosantos9521
Copy link
Contributor

@ricardosantos9521 ricardosantos9521 commented Jan 5, 2022

Summary of the Pull Request

What is this about:
VSCode insiders 1.64 has a new file for workspaces. This is pull request is to add support to the new file.

What is included in the PR:
Use the new file Backups/workspaces.json instead of storage.json

How does someone test / validate:

  • Install lastest version of vscode-insiders.
  • Open multiple project folders/workspaces or remote containers
  • by typing { in Powertoys all the projects and workspaces from vscodeinsiders should appear in the result list

Quality Checklist

  • Linked issue: VScode workspaces does not show up #15247
  • Communication: I've discussed this with core contributors in the issue.
  • Tests: Added/updated and all pass
  • Installer: Added/updated and all pass
  • Localization: All end user facing strings can be localized
  • Docs: Added/ updated
  • Binaries: Any new files are added to WXS / YML

Contributor License Agreement (CLA)

A CLA must be signed. If not, go over here and sign the CLA.

@ricardosantos9521 ricardosantos9521 changed the title Powertoys Run | VSCodeWorkspaces- add support for vscode 1.64 - bug fix #15106 Powertoys Run | VSCodeWorkspaces- add support for vscode 1.64 - bug fix #15247 Jan 5, 2022
@@ -70,7 +73,7 @@ public List<VSCodeWorkspace> Workspaces
{
VSCodeStorageFile vscodeStorageFile = JsonSerializer.Deserialize<VSCodeStorageFile>(fileContent);

if (vscodeStorageFile != null)
if (vscodeStorageFile != null && vscodeStorageFile.OpenedPathsList != null)
Copy link
Collaborator

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 ?

Copy link
Contributor Author

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.

@ricardosantos9521
Copy link
Contributor Author

ricardosantos9521 commented Jan 5, 2022

I found an issue with this solution please don't merge it. When we open a workspace, the workspace appears to be added in Backups/workspace.json.

But when we remove the workspace from the vscode dropdown in the taskbar the file doesn't appear to be synced.
image

And i think while testing it, vscode removed all the folderWorkspaceInfos from Backups/workspace.json at least one of the times.

I will create a bug in vscode repository to see if vscode team have any alternative to get the previous open workspaces in vscode 1.64 or later

microsoft/vscode#140181

@Aaron-Junker
Copy link
Collaborator

@jaimecbernardo So a merge blocking bug was found here. So I guess we will release this not with 0.53 right?

@jaimecbernardo
Copy link
Collaborator

Yes, guess this will be targeted at 0.55.

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

@check-spelling-bot Report

🔴 Please review

See the files view or the action log for details.

Unrecognized words (3)

datareader
sqlite
vscdb

Previously acknowledged words that are now absent ChaseKnowlden CleanCodeDeveloper CTLCOLORSTATIC Deuchert efgh errc Grayscale iccex ICONINFORMATION INITCOMMONCONTROLSEX INSTALLLOGATTRIBUTES INSTALLLOGMODE INSTALLUILEVEL MAINICON MAKELPARAM msiexec MSIINSTALLER NATIVEFNTCTL netlify Qin rdeveen rexit SETRANGE SETSTEP sregex STEPIT symlink UITo We'd
To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the git@github.com:ricardosantos9521/PowerToys.git repository
on the dev/15106 branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/whitelist.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
-H "Content-Type: application/json" \
"https://api.github.com/repos/microsoft/PowerToys/issues/comments/1006965025" > "$comment_json"
comment_body=$(mktemp)
jq -r ".body // empty" "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")

patch_add=$(perl -e '$/=undef; $_=<>; if (m{Unrecognized words[^<]*</summary>\n*```\n*([^<]*)```\n*</details>$}m) { print "$1" } elsif (m{Unrecognized words[^<]*\n\n((?:\w.*\n)+)\n}m) { print "$1" };' < "$comment_body")

update_files
rm $comment_body
git add -u

@ricardosantos9521
Copy link
Contributor Author

ricardosantos9521 commented Jan 6, 2022

I think i fixed the issue. I'm obtaining the previous opened workspaces from AppData\Roaming\Code - Insiders\User\globalStorage\state.vscdb a sqlite db. I added the package Microsoft.Data.Sqlite do i need to add it somewhere else?

@stefansjfw

@stefansjfw
Copy link
Collaborator

I think i fixed the issue. I'm obtaining the previous opened workspaces from AppData\Roaming\Code - Insiders\User\globalStorage\state.vscdb a sqlite db. I added the package Microsoft.Data.Sqlite do i need to add it somewhere else?

@stefansjfw

yes, installer should probably be updated. Let me check

@stefansjfw
Copy link
Collaborator

stefansjfw commented Jan 12, 2022

yes, check this line https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs#L1333

Before modifying installer, try building the PowerToys installer like this (in developer CMD for Visual Studio) and install PT:

nuget.exe restore
MSBuild -m .\PowerToys.sln /p:Configuration=Release /p:Platform="x64"
nuget.exe restore .\tools\BugReportTool\
MSBuild -m .\tools\BugReportTool\BugReportTool.sln /p:Configuration=Release /p:Platform="x64"
nuget.exe restore .\tools\WebcamReportTool\
MSBuild -m .\tools\WebcamReportTool\WebcamReportTool.sln /p:Configuration=Release /p:Platform="x64"
nuget.exe restore .\installer\
MSBuild -m .\installer\PowerToysSetup.sln /target:PowerToysInstaller /p:Configuration=Release /p:Platform="x64"
MSBuild -m .\installer\PowerToysSetup.sln /p:Configuration=Release /p:Platform="x64"

My guess is that when you try to test VSCodeWorkspaces plugin - part with reading the database, it will crash.

@ricardosantos9521
Copy link
Contributor Author

@stefansjfw the installer is working now

@jaimecbernardo
Copy link
Collaborator

Hi @ricardosantos9521,
I feel like the merge didn't work as expected. The changeset on github is showing changes on different files. Perhaps a merge from the 'main' branch will fix it.

@ricardosantos9521
Copy link
Contributor Author

Hi @ricardosantos9521, I feel like the merge didn't work as expected. The changeset on github is showing changes on different files. Perhaps a merge from the 'main' branch will fix it.

done

@@ -106,6 +110,50 @@ public List<VSCodeWorkspace> Workspaces
}
}
}
else if (File.Exists(vscode_storage_db))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be inside if (File.Exists(vscode_storage)). Does db logic depend on existence of vscode_storage file? I.e. can we still read workspaces from DB if there is no vscode_storage file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we can't read workspaces if there's no vscode_storage.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that one question I wrote, looks good! Nice work!

@stefansjfw stefansjfw merged commit 758a21a into microsoft:main Jan 18, 2022
@ricardosantos9521 ricardosantos9521 deleted the dev/15106 branch January 18, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants