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

[PT Run][New Plugin] Unit Converter #9800

Merged

Conversation

ThiefZero
Copy link
Contributor

@ThiefZero ThiefZero commented Feb 19, 2021

Summary of the Pull Request

What is this about:
A unit converter plugin for PowerToys.Run. I've had this idea for a while now and wanted to see if I could contribute to my first open source project. (I hadn't opened an issue yet because I wanted to see if I could make it work.)
As it's my first open source contribution constructive feedback is appreciated ✌️.
I'm using a package called UnitsNet to do these conversions.
image
image
image

What is included in the PR:

Currently Supported Units (13)

How does someone test / validate:
Manually, or running the unit tests.

Possible Improvements

  • Temperature names are prefixed with Degree (e.g. DegreeCelsius/DegreeFahrenheit), make sure words without the prefix (e.g. 'celsius') suffices.
  • Temperature shorthand needs a degree symbol to work correctly, make sure it doesn't (e.g. '10 f in c' should work).
  • Sometimes stuff like '1'5" in cm' returns scientific power to 10th notation (e.g. '4,3179999999999994E+17'). This should probably just round (e.g. to '4,318').
  • Culture dependent input should work (use of ',' or '.').
  • Support multiple length input such as '1 foot 5 inch in cm'. (?)
  • Support 'copy to clipboard' translations.
  • Change to use the keywords 'to' and 'in' (if it's even possible to use multiple keywords, find out).

Quality Checklist

  • Linked issue: As stated, I didn't open an issue before doing work (I know, very naughty) but it seems like there's an issue for it now: [PowerToys Run] Unit conversion #9577
  • 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.

@ghost
Copy link

ghost commented Feb 19, 2021

CLA assistant check
All CLA requirements met.

@github-actions
Copy link

New misspellings found, please review:

  • Prefixer
  • shortsplit
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"acf Actionkeyword bdaa benjamhooper bsearch deondre Elems eriawan FDFC FFB filesfolder globalplugins happlebao HKE jhutchings jsoref msazure MSGBOX netfx QWORD removefolder Runtimes Rutkas Searcn Segoe snickler systray verifybothfolderfilesequal welcomeoverview XJson YJson "');
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)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"NETFX Prefixer qword runtimes segoe shortsplit "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check || echo '... you want to ensure .github/actions/spell-check/expect.txt is added to your repository...'

@enricogior enricogior added the Run-Plugin Things that relate with PowerToys Run's plugin interface label Feb 26, 2021
@crutkas
Copy link
Member

crutkas commented Mar 1, 2021

This is missing the WSX adjustments no matter what for installer

@github-actions
Copy link

github-actions bot commented Mar 3, 2021

New misspellings found, please review:

  • Prefixer
  • shortsplit
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"acf Actionkeyword bdaa benjamhooper bsearch deondre Elems eriawan FDFC FFB filesfolder globalplugins happlebao HKE jhutchings jsoref msazure MSGBOX netfx QWORD removefolder Runtimes Rutkas Searcn Segoe snickler systray verifybothfolderfilesequal welcomeoverview XJson YJson "');
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)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"NETFX Prefixer qword runtimes segoe shortsplit "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check || echo '... you want to ensure .github/actions/spell-check/expect.txt is added to your repository...'

1 similar comment
@github-actions
Copy link

github-actions bot commented Mar 3, 2021

New misspellings found, please review:

  • Prefixer
  • shortsplit
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"acf Actionkeyword bdaa benjamhooper bsearch deondre Elems eriawan FDFC FFB filesfolder globalplugins happlebao HKE jhutchings jsoref msazure MSGBOX netfx QWORD removefolder Runtimes Rutkas Searcn Segoe snickler systray verifybothfolderfilesequal welcomeoverview XJson YJson "');
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)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"NETFX Prefixer qword runtimes segoe shortsplit "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check || echo '... you want to ensure .github/actions/spell-check/expect.txt is added to your repository...'

@enricogior
Copy link
Contributor

@enricogior enricogior marked this pull request as draft March 5, 2021 11:08
@ThiefZero
Copy link
Contributor Author

@ThiefZero
there are build errors, can you fix them?
https://github.com/microsoft/PowerToys/pull/9800/checks?check_run_id=2024088270

Working on it. Added the interface members but breaks on not having the get_name in the .dll. Not sure what's going on yet.

@ThiefZero ThiefZero force-pushed the unitConversion branch 2 times, most recently from bf31995 to 5b99a38 Compare March 5, 2021 20:50
@github-actions
Copy link

github-actions bot commented Mar 5, 2021

New misspellings found, please review:

  • Prefixer
  • shortsplit
  • unitconverter
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"cimv devenv gwmi Iconsempty itsme pavelzw proactively returnvalue settingsui sideload sideloading TRCA "');
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)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"Prefixer shortsplit unitconverter "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check || echo '... you want to ensure .github/actions/spell-check/expect.txt is added to your repository...'

@enricogior
Copy link
Contributor

@ThiefZero
can you add the following terms to https://github.com/microsoft/PowerToys/blob/master/.github/actions/spell-check/expect.txt? Thanks

Prefixer
shortsplit
unitconvert
unitconverter

@MaddyGuthridge
Copy link

Would it be possible to have it also work for "to" as well as "in"; eg "10 m/s to km/h"?

@ThiefZero
Copy link
Contributor Author

ThiefZero commented Mar 22, 2021

Would it be possible to have it also work for "to" as well as "in"; eg "10 m/s to km/h"?

It's on my list of improvements, haven't looked into it yet but I hope it's possible!

edit:
Checked my code, it doesn't look at what 'keyword' you use but checks for the units. This means 'to' and 'in' both work.
image

@enricogior
Copy link
Contributor

@ThiefZero
is the PR ready for the final review? If it is, let's convert it from draft to ready for review, thanks.

@ThiefZero
Copy link
Contributor Author

@ThiefZero
is the PR ready for the final review? If it is, let's convert it from draft to ready for review, thanks.

Hi! Yes, I'd like some feedback on the PR. Not sure if the feature is implemented OK and if I'm missing anything. If it's OK then maybe I can add some tests later (don't know how yet).

@ThiefZero ThiefZero marked this pull request as ready for review April 3, 2021 16:25
@htcfreek
Copy link
Collaborator

htcfreek commented Apr 3, 2021

@ThiefZero
I think we should have an own plugin symbol/icon for each plugin. So we can't use the same icon as on calculator plugin. Maybe @niels9001 or someone of the other contributors has an idea. 😉

@htcfreek
Copy link
Collaborator

htcfreek commented Apr 7, 2021

@ThiefZero
What is the remaining work here?

Copy link
Collaborator

@htcfreek htcfreek left a comment

Choose a reason for hiding this comment

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

Some suggestions and questions.

<value>Provides unit conversion.</value>
</data>
<data name="wox_plugin_unitconverter_plugin_name" xml:space="preserve">
<value>UnitConverter</value>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<value>UnitConverter</value>
<value>Unit Converter</value>

<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="wox_plugin_unitconverter_plugin_description" xml:space="preserve">
Copy link
Collaborator

@htcfreek htcfreek Apr 7, 2021

Choose a reason for hiding this comment

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

Why Wox is used here and at the other entries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the naming scheme found in the calculator plugin. Doesn't seem to matter, consider it removed 👍

"Author": "ThiefZero",
"Version": "0.0.1",
"Language": "csharp",
"Website": "https://github.com/ThiefZero/PowerToys",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think this must be the Microsoft/PowerToys repository.

Copy link
Member

Choose a reason for hiding this comment

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

"ID": "aa0ee9daff654fb7be452c2d77c471b9",
"ActionKeyword": "*",
"IsGlobal": true,
"Name": "UnitConverter",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"Name": "UnitConverter",
"Name": "Unit Converter",

@ThiefZero
Copy link
Contributor Author

ThiefZero commented Apr 8, 2021

@ThiefZero
What is the remaining work here?

Most importantly getting the culture right (for use of . vs ,). After that it should be good enough to be used. Bonus are tests if I can figure out how to make them 😄
Oh, and probably a custom icon. No clues there yet though.

@ThiefZero
Copy link
Contributor Author

Should be good to go now. Only missing a custom icon.

@ThiefZero ThiefZero requested a review from htcfreek April 14, 2021 09:09
@niels9001
Copy link
Contributor

niels9001 commented Apr 14, 2021

@ThiefZero

I think the 'Unit' icon is applicable for this converter. Here are the dark and light images (with the right dimensions) for that (the dark icon is there, just not visible because it's white-on-white :)):

unitconverter dark
unitconverter light

@ThiefZero ThiefZero requested a review from crutkas April 16, 2021 22:59
@htcfreek
Copy link
Collaborator

htcfreek commented Apr 17, 2021

@ThiefZero
At the moment I am testing the plugin in a local build.

  • The first thing I saw is that the result are included in global results. I think we should change the default behavior here.
  • On German culture settings the dot is ignored and 5.5 is interpret as 55. This can be confusing. Do you have an idea how we could improve this case?
  • We should add a list to docs which units can be converted.
  • Can we remove the requirement of a space between number and unit.
  • We should should show a warning on unsupported input like this *4 m² in m or *5 m in t.
    • Suggestion: Unit conversation or input not supported.
  • Are units like m², m³ supported?

@github-actions
Copy link

github-actions bot commented May 19, 2021

@check-spelling-bot Report

Unrecognized words, please review:

  • Hrenhei
Previously acknowledged words that are now absent apos bc bh Chris's classmethod cls cn cx cz df dw EB ev fd fody fx getmembers gh hc hh hk hu ip ismethod jp Kf lambson laute loadingbar messagebox NX pb Pn pv pw px QI rpc ru rv rx sz tadele td tt tw Tz ul unitconvert uv vh vk vm vw Vx xa XY yy Zc zh zm
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:ThiefZero/PowerToys.git repository
on the unitConversion branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.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/spell-check/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 \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/PowerToys/issues/comments/844097357" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$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;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u
If you see a bunch of garbage

If it relates to a ...

well-formed pattern

See if there's a pattern that would match it.

If not, try writing one and adding it to the patterns.txt file.

Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

Note that patterns can't match multiline strings.

binary-ish string

Please add a file path to the excludes.txt file instead of just accepting the garbage.

File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

@ThiefZero
Copy link
Contributor Author

The UnitsNet.dll dependency needs to be added to the installer.

Nice catch, I added this in my local build and build the release version, then the release version of the installer. I installed (after clearing PowerToys folder from AppData) and tried running Run, but can't. I never have been able to in the past, but I figured it was something on my machine. Now that you've mentioned I was missing a .dll, I'm thinking I might have missed something else.
I tried looking into the launcher-log but all I'm getting is

[2021-05-19 14:57:07.434985] [p-16488] [t-17196] [info] launcher logger is initialized
[2021-05-19 14:57:07.434998] [p-16488] [t-17196] [info] Launcher object is constructing
[2021-05-19 14:57:07.435153] [p-16488] [t-17196] [info] PT Run settings are empty
[2021-05-19 14:57:07.435154] [p-16488] [t-17196] [info] PT Run is going to use default shortcut
[2021-05-19 14:57:07.632297] [p-16488] [t-17196] [info] Launcher is enabling
[2021-05-19 14:57:07.632310] [p-16488] [t-17196] [trace] Starting PowerToys Run from elevated process
[2021-05-19 14:57:07.636094] [p-16488] [t-17196] [error] Failed to start PowerToys Run
[2021-05-19 14:57:17.062502] [p-16488] [t-17196] [info] Launcher is enabling
[2021-05-19 14:57:17.062521] [p-16488] [t-17196] [trace] Starting PowerToys Run from elevated process
[2021-05-19 14:57:17.066283] [p-16488] [t-17196] [error] Failed to start PowerToys Run
[2021-05-19 15:04:39.865215] [p-16488] [t-17196] [info] Launcher object is destroying
[2021-05-19 15:04:44.252379] [p-15332] [t-15312] [info] launcher logger is initialized
[2021-05-19 15:04:44.252414] [p-15332] [t-15312] [info] Launcher object is constructing
[2021-05-19 15:07:20.157885] [p-15332] [t-15312] [info] Launcher is enabling
[2021-05-19 15:07:20.157905] [p-15332] [t-15312] [trace] Starting PowerToys Run from elevated process
[2021-05-19 15:07:20.161629] [p-15332] [t-15312] [error] Failed to start PowerToys Run

Any thoughts on how to debug it?

@enricogior
Copy link
Contributor

@ThiefZero
you can open the Event Log -> Windows Logs -> Application and it should show the reason.
That is the error that I was getting because of the missing UnitsNet.dll, after I manually copied to the UnitConverter folder it went away.

@htcfreek
Copy link
Collaborator

htcfreek commented May 19, 2021

@ThiefZero
you can open the Event Log -> Windows Logs -> Application and it should show the reason.
That is the error that I was getting because of the missing UnitsNet.dll, after I manually copied to the UnitConverter folder it went away.

@enricogior , @ThiefZero
Why is the complete launcher instead of only the plugin failed to start?

And can we catch it with the "Something went wrong ux"?

Can we do some improvements here in a second step?

@ThiefZero
Copy link
Contributor Author

@ThiefZero
you can open the Event Log -> Windows Logs -> Application and it should show the reason.
That is the error that I was getting because of the missing UnitsNet.dll, after I manually copied to the UnitConverter folder it went away.

@enricogior , @ThiefZero
Why is the complete launcher instead of only the plugin failed to start?

And can we catch it with the "Something went wrong ux"?

Can we do some improvements here in a second step?

I just rebuild the Master branch on release and the installer on release as well to test, still can't get Run to launch.
I checked the Application logs (Event Viewer) but there's no error/warning being logged there. I noticed on the Run page the Plugin list never gets loaded.

I don't think this has anything to do with the UnitConverter, it's probably something with my machine if it works fine on yours.

@htcfreek
Copy link
Collaborator

@ThiefZero
you can open the Event Log -> Windows Logs -> Application and it should show the reason.
That is the error that I was getting because of the missing UnitsNet.dll, after I manually copied to the UnitConverter folder it went away.

@enricogior , @ThiefZero
Why is the complete launcher instead of only the plugin failed to start?

And can we catch it with the "Something went wrong ux"?

Can we do some improvements here in a second step?

I just rebuild the Master branch on release and the installer on release as well to test, still can't get Run to launch.
I checked the Application logs (Event Viewer) but there's no error/warning being logged there. I noticed on the Run page the Plugin list never gets loaded.

I don't think this has anything to do with the UnitConverter, it's probably something with my machine if it works fine on yours.

Did you run something in an other user context? There is a bug regarding settings.json of pt run.

@ThiefZero
Copy link
Contributor Author

Did you run something in an other user context? There is a bug regarding settings.json of pt run.

That was it, apparently had to uncheck run as admin in the .exe 👍 (didn't know that would persist through reinstalls). Just rebuilt everything on Release and everything works now

@htcfreek
Copy link
Collaborator

Did you run something in an other user context? There is a bug regarding settings.json of pt run.

That was it, apparently had to uncheck run as admin in the .exe 👍 (didn't know that would persist through reinstalls). Just rebuilt everything on Release and everything works now

This persist after deleting the exe file too.

We have an open issue on this bug. I`ll link to this comments.

@enricogior enricogior changed the base branch from master to user/ThiefZero/unitConversion May 21, 2021 14:40
@enricogior
Copy link
Contributor

@ThiefZero
I've changed the target branch for this PR from master to user/ThiefZero/unitConversion so we can work on it to complete the work before merging it to master.
Thanks

@github-actions
Copy link

github-actions bot commented May 21, 2021

@check-spelling-bot Report

Unrecognized words, please review:

  • Hrenhei
Previously acknowledged words that are now absent apos autoupdate bc bh Chris's classmethod cls CMDARG cn cx cz deque df dw EB ev fd fody fx getmembers gh hc hh hk hu ip ismethod jp Kf lambson laute loadingbar messagebox multithreading nonwin NX overlaywindow pb Pn pv pw px QI rpc ru rv rx Shortcutguide sz tadele td tt tw Tz ul unitconvert uv vh vk vm vw Vx wostringstream xa XY yy Zc zh zipfolder zm
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:ThiefZero/PowerToys.git repository
on the unitConversion branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect.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/spell-check/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 \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/PowerToys/issues/comments/846008022" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$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;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u
If you see a bunch of garbage

If it relates to a ...

well-formed pattern

See if there's a pattern that would match it.

If not, try writing one and adding it to the patterns.txt file.

Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

Note that patterns can't match multiline strings.

binary-ish string

Please add a file path to the excludes.txt file instead of just accepting the garbage.

File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

@enricogior enricogior merged commit c063b86 into microsoft:user/ThiefZero/unitConversion May 21, 2021
enricogior added a commit that referenced this pull request May 21, 2021
* [wip] add unit converter plugin

* Plugin loads and accepts queries

* Update csproj, add UnitConversion package, WIP

* Switch unit conversion packages, add first convert logic

* Move unitconverter to correct solution

* Unitconversion supports double unabbreviated unitnames

* Units convert with 1 abbreviation and 1 unabbreviated

* Feature: make shorthand feet/inch notation work

* Update to new naming scheme

* Rename to community

* Shorthand ft/in notation supports decimals.

* Update plugin.json

* Fix decimal/cultureInfo issue

* Update plugin.json

* Add degree prefixer function

* Add unitConverter to wxs installer

* Add name/description for interface

* Add english translation, separate input parsing functions

* Add words to spell-check

* Add result rounding

* PR feedback (rename stuff)

* Unit conversion takes culture into account

* Add InputInterpreter tests, small cleanup

* Split conversion logic, add integration tests

* Fix improper resource property names

* [UnitConverter] Add image from niels9001. Fix exception error. Add function summaries.

* [UnitConverter] Update image in installer

* [UnitConverter] Support inputs without space (eg. 1cm to mm)

* [UnitConverter] Add doc. Add more units. Update test packages.

* [UnitConverter] Fix bug, regular unit conversion AND kB kb capital differences are recognized and work

* [UnitConverter] Add doc img, fix spelling

* [UnitConverter] Add byte capital test, just in case

* [UnitConverter] Add unit tests to pipeline test build step

* [UnitConverter] Change test to x64 from Any CPU. Fix issue where conversion to feet did not use cultureInfo.

* [UnitConverter] Fix build config

* removing allcpu
forcing this to be global
correcting depencies on launcher

* [UnitConverter] Fix bug in degree conversion. Add unit to display result. Fix rounding display/value mismatch.

* [UnitConverter] Improve test

* [UnitConverter] Add Stylecop package, fix formatting, add
GlobalSuppressions.cs

* [UnitConverter] Change actionkeyword, more formatting

* [UnitConverter] Add context menu to conversion results

* [UnitConverter] Disable global

* [UnitConverter] Add UnitsNet.dll to installer, insert example in description

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
jsoref pushed a commit to check-spelling-sandbox/PowerToys that referenced this pull request May 24, 2021
* [wip] add unit converter plugin

* Plugin loads and accepts queries

* Update csproj, add UnitConversion package, WIP

* Switch unit conversion packages, add first convert logic

* Move unitconverter to correct solution

* Unitconversion supports double unabbreviated unitnames

* Units convert with 1 abbreviation and 1 unabbreviated

* Feature: make shorthand feet/inch notation work

* Update to new naming scheme

* Rename to community

* Shorthand ft/in notation supports decimals.

* Update plugin.json

* Fix decimal/cultureInfo issue

* Update plugin.json

* Add degree prefixer function

* Add unitConverter to wxs installer

* Add name/description for interface

* Add english translation, separate input parsing functions

* Add words to spell-check

* Add result rounding

* PR feedback (rename stuff)

* Unit conversion takes culture into account

* Add InputInterpreter tests, small cleanup

* Split conversion logic, add integration tests

* Fix improper resource property names

* [UnitConverter] Add image from niels9001. Fix exception error. Add function summaries.

* [UnitConverter] Update image in installer

* [UnitConverter] Support inputs without space (eg. 1cm to mm)

* [UnitConverter] Add doc. Add more units. Update test packages.

* [UnitConverter] Fix bug, regular unit conversion AND kB kb capital differences are recognized and work

* [UnitConverter] Add doc img, fix spelling

* [UnitConverter] Add byte capital test, just in case

* [UnitConverter] Add unit tests to pipeline test build step

* [UnitConverter] Change test to x64 from Any CPU. Fix issue where conversion to feet did not use cultureInfo.

* [UnitConverter] Fix build config

* removing allcpu
forcing this to be global
correcting depencies on launcher

* [UnitConverter] Fix bug in degree conversion. Add unit to display result. Fix rounding display/value mismatch.

* [UnitConverter] Improve test

* [UnitConverter] Add Stylecop package, fix formatting, add
GlobalSuppressions.cs

* [UnitConverter] Change actionkeyword, more formatting

* [UnitConverter] Add context menu to conversion results

* [UnitConverter] Disable global

* [UnitConverter] Add UnitsNet.dll to installer, insert example in description

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
jsoref pushed a commit to check-spelling-sandbox/PowerToys that referenced this pull request May 24, 2021
* [wip] add unit converter plugin

* Plugin loads and accepts queries

* Update csproj, add UnitConversion package, WIP

* Switch unit conversion packages, add first convert logic

* Move unitconverter to correct solution

* Unitconversion supports double unabbreviated unitnames

* Units convert with 1 abbreviation and 1 unabbreviated

* Feature: make shorthand feet/inch notation work

* Update to new naming scheme

* Rename to community

* Shorthand ft/in notation supports decimals.

* Update plugin.json

* Fix decimal/cultureInfo issue

* Update plugin.json

* Add degree prefixer function

* Add unitConverter to wxs installer

* Add name/description for interface

* Add english translation, separate input parsing functions

* Add words to spell-check

* Add result rounding

* PR feedback (rename stuff)

* Unit conversion takes culture into account

* Add InputInterpreter tests, small cleanup

* Split conversion logic, add integration tests

* Fix improper resource property names

* [UnitConverter] Add image from niels9001. Fix exception error. Add function summaries.

* [UnitConverter] Update image in installer

* [UnitConverter] Support inputs without space (eg. 1cm to mm)

* [UnitConverter] Add doc. Add more units. Update test packages.

* [UnitConverter] Fix bug, regular unit conversion AND kB kb capital differences are recognized and work

* [UnitConverter] Add doc img, fix spelling

* [UnitConverter] Add byte capital test, just in case

* [UnitConverter] Add unit tests to pipeline test build step

* [UnitConverter] Change test to x64 from Any CPU. Fix issue where conversion to feet did not use cultureInfo.

* [UnitConverter] Fix build config

* removing allcpu
forcing this to be global
correcting depencies on launcher

* [UnitConverter] Fix bug in degree conversion. Add unit to display result. Fix rounding display/value mismatch.

* [UnitConverter] Improve test

* [UnitConverter] Add Stylecop package, fix formatting, add
GlobalSuppressions.cs

* [UnitConverter] Change actionkeyword, more formatting

* [UnitConverter] Add context menu to conversion results

* [UnitConverter] Disable global

* [UnitConverter] Add UnitsNet.dll to installer, insert example in description

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
jsoref pushed a commit to check-spelling-sandbox/PowerToys that referenced this pull request May 24, 2021
* [wip] add unit converter plugin

* Plugin loads and accepts queries

* Update csproj, add UnitConversion package, WIP

* Switch unit conversion packages, add first convert logic

* Move unitconverter to correct solution

* Unitconversion supports double unabbreviated unitnames

* Units convert with 1 abbreviation and 1 unabbreviated

* Feature: make shorthand feet/inch notation work

* Update to new naming scheme

* Rename to community

* Shorthand ft/in notation supports decimals.

* Update plugin.json

* Fix decimal/cultureInfo issue

* Update plugin.json

* Add degree prefixer function

* Add unitConverter to wxs installer

* Add name/description for interface

* Add english translation, separate input parsing functions

* Add words to spell-check

* Add result rounding

* PR feedback (rename stuff)

* Unit conversion takes culture into account

* Add InputInterpreter tests, small cleanup

* Split conversion logic, add integration tests

* Fix improper resource property names

* [UnitConverter] Add image from niels9001. Fix exception error. Add function summaries.

* [UnitConverter] Update image in installer

* [UnitConverter] Support inputs without space (eg. 1cm to mm)

* [UnitConverter] Add doc. Add more units. Update test packages.

* [UnitConverter] Fix bug, regular unit conversion AND kB kb capital differences are recognized and work

* [UnitConverter] Add doc img, fix spelling

* [UnitConverter] Add byte capital test, just in case

* [UnitConverter] Add unit tests to pipeline test build step

* [UnitConverter] Change test to x64 from Any CPU. Fix issue where conversion to feet did not use cultureInfo.

* [UnitConverter] Fix build config

* removing allcpu
forcing this to be global
correcting depencies on launcher

* [UnitConverter] Fix bug in degree conversion. Add unit to display result. Fix rounding display/value mismatch.

* [UnitConverter] Improve test

* [UnitConverter] Add Stylecop package, fix formatting, add
GlobalSuppressions.cs

* [UnitConverter] Change actionkeyword, more formatting

* [UnitConverter] Add context menu to conversion results

* [UnitConverter] Disable global

* [UnitConverter] Add UnitsNet.dll to installer, insert example in description

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
jsoref pushed a commit to check-spelling-sandbox/PowerToys that referenced this pull request May 24, 2021
* [wip] add unit converter plugin

* Plugin loads and accepts queries

* Update csproj, add UnitConversion package, WIP

* Switch unit conversion packages, add first convert logic

* Move unitconverter to correct solution

* Unitconversion supports double unabbreviated unitnames

* Units convert with 1 abbreviation and 1 unabbreviated

* Feature: make shorthand feet/inch notation work

* Update to new naming scheme

* Rename to community

* Shorthand ft/in notation supports decimals.

* Update plugin.json

* Fix decimal/cultureInfo issue

* Update plugin.json

* Add degree prefixer function

* Add unitConverter to wxs installer

* Add name/description for interface

* Add english translation, separate input parsing functions

* Add words to spell-check

* Add result rounding

* PR feedback (rename stuff)

* Unit conversion takes culture into account

* Add InputInterpreter tests, small cleanup

* Split conversion logic, add integration tests

* Fix improper resource property names

* [UnitConverter] Add image from niels9001. Fix exception error. Add function summaries.

* [UnitConverter] Update image in installer

* [UnitConverter] Support inputs without space (eg. 1cm to mm)

* [UnitConverter] Add doc. Add more units. Update test packages.

* [UnitConverter] Fix bug, regular unit conversion AND kB kb capital differences are recognized and work

* [UnitConverter] Add doc img, fix spelling

* [UnitConverter] Add byte capital test, just in case

* [UnitConverter] Add unit tests to pipeline test build step

* [UnitConverter] Change test to x64 from Any CPU. Fix issue where conversion to feet did not use cultureInfo.

* [UnitConverter] Fix build config

* removing allcpu
forcing this to be global
correcting depencies on launcher

* [UnitConverter] Fix bug in degree conversion. Add unit to display result. Fix rounding display/value mismatch.

* [UnitConverter] Improve test

* [UnitConverter] Add Stylecop package, fix formatting, add
GlobalSuppressions.cs

* [UnitConverter] Change actionkeyword, more formatting

* [UnitConverter] Add context menu to conversion results

* [UnitConverter] Disable global

* [UnitConverter] Add UnitsNet.dll to installer, insert example in description

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
ThiefZero added a commit to ThiefZero/PowerToys that referenced this pull request May 28, 2021
* [wip] add unit converter plugin

* Plugin loads and accepts queries

* Update csproj, add UnitConversion package, WIP

* Switch unit conversion packages, add first convert logic

* Move unitconverter to correct solution

* Unitconversion supports double unabbreviated unitnames

* Units convert with 1 abbreviation and 1 unabbreviated

* Feature: make shorthand feet/inch notation work

* Update to new naming scheme

* Rename to community

* Shorthand ft/in notation supports decimals.

* Update plugin.json

* Fix decimal/cultureInfo issue

* Update plugin.json

* Add degree prefixer function

* Add unitConverter to wxs installer

* Add name/description for interface

* Add english translation, separate input parsing functions

* Add words to spell-check

* Add result rounding

* PR feedback (rename stuff)

* Unit conversion takes culture into account

* Add InputInterpreter tests, small cleanup

* Split conversion logic, add integration tests

* Fix improper resource property names

* [UnitConverter] Add image from niels9001. Fix exception error. Add function summaries.

* [UnitConverter] Update image in installer

* [UnitConverter] Support inputs without space (eg. 1cm to mm)

* [UnitConverter] Add doc. Add more units. Update test packages.

* [UnitConverter] Fix bug, regular unit conversion AND kB kb capital differences are recognized and work

* [UnitConverter] Add doc img, fix spelling

* [UnitConverter] Add byte capital test, just in case

* [UnitConverter] Add unit tests to pipeline test build step

* [UnitConverter] Change test to x64 from Any CPU. Fix issue where conversion to feet did not use cultureInfo.

* [UnitConverter] Fix build config

* removing allcpu
forcing this to be global
correcting depencies on launcher

* [UnitConverter] Fix bug in degree conversion. Add unit to display result. Fix rounding display/value mismatch.

* [UnitConverter] Improve test

* [UnitConverter] Add Stylecop package, fix formatting, add
GlobalSuppressions.cs

* [UnitConverter] Change actionkeyword, more formatting

* [UnitConverter] Add context menu to conversion results

* [UnitConverter] Disable global

* [UnitConverter] Add UnitsNet.dll to installer, insert example in description

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
jaimecbernardo added a commit that referenced this pull request Jun 9, 2021
This reverts commit 1dabd76,
to give proper attribution to the author.
jaimecbernardo added a commit that referenced this pull request Jun 9, 2021
This reverts commit 1dabd76,
to give proper attribution to the author.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run-Plugin Things that relate with PowerToys Run's plugin interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants