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] Allow interchangeable use of / instead of \ #33309

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

GhostVaibhav
Copy link
Contributor

@GhostVaibhav GhostVaibhav commented Jun 9, 2024

Summary of the Pull Request

As the title suggests, the PR adds the feature of using / instead of \ in the Registry plugin of PT Run.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

  • Manually tested by inputting registry paths with /
  • Also added tests for the same

@GhostVaibhav GhostVaibhav marked this pull request as ready for review June 11, 2024 16:38
@GhostVaibhav
Copy link
Contributor Author

Hi @htcfreek, I wrote some code. Can you review it, please? Also, I'm very new to testing, so could you point out some docs to get help regarding the same? Thanks.

@htcfreek
Copy link
Collaborator

Screenshot of both input formats would be great in the first place.

@GhostVaibhav
Copy link
Contributor Author

GhostVaibhav commented Jun 11, 2024

Hi @htcfreek, I didn't quite get you. I have attached some screenshots regarding the new syntax -

image

image

image

image

image

Some screenshots of the old syntax -

image

image

@htcfreek
Copy link
Collaborator

Do we need the " in the result of screenshot 5?

@GhostVaibhav
Copy link
Contributor Author

Do we need the " in the result of screenshot 5?

No, we don't. Will be removing in the next commit.

@GhostVaibhav
Copy link
Contributor Author

Hi @htcfreek, I wrote some code. Can you review it, please? Also, I'm very new to testing, so could you point out some docs to get help regarding the same? Thanks.

Hi @htcfreek, any updates on this? Also, @jaimecbernardo, if you could comment on the testing part?

@jaimecbernardo
Copy link
Collaborator

Hi @GhostVaibhav,
Thanks for opening the PR.
Tests are in "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.Registry.UnitTest\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.csproj", which is also part of the PowerToys solution.
You can run tests from the Test > Test Explorer in Visual Studio.
Can use the other tests that are there as a basis. 😉
Hope this helps. Thank you!

@htcfreek
Copy link
Collaborator

Had no time to test yet. Hopefully on weekend.

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.

There is a bug regarding the input parsing:

  1. If I have a key "test" and a key "test/test" typing the "t" before the slash removes the key containing the slash from the result list and typing the whole key name clear the result list.
    run-reg-slash

image
2. The result for key structuer with a key containing a slash is wrong. Looks like the splitting counter behaves wrong.
image
image
3. I can't show the contents of a key that's name contains a slash and all their subkeys:
image

@GhostVaibhav
Copy link
Contributor Author

Hi @htcfreek and @jaimecbernardo, thank you both for your valuable input. However, I think I have hit a roadblock while figuring out, how to replace the / with the \. I am still trying to figure out the correct regex for that. It would be of great help if you have any inputs regarding the same. I have opened it as a question on StackOverflow (linked here). Thanks!

@GhostVaibhav
Copy link
Contributor Author

GhostVaibhav commented Jun 17, 2024

Hi @htcfreek, I resolved all of the bugs that you pointed out while you were testing and added some tests for the same. However, the first one is not a bug from my code, but a bug in the underlying System.Registry plugin that is used to get the data for the context menu. You can test it in the latest stable version, and the result is the same.

@htcfreek
Copy link
Collaborator

However, the first one is not a bug from my code, but a bug in the underlying System.Registry plugin that is used to get the data for the context menu. You can test it in the latest stable version, and the result is the same.

Hi @GhostVaibhav .
We should open a issue for that in our repo to fix this in a second step. Or did you fixed it too?

@GhostVaibhav
Copy link
Contributor Author

GhostVaibhav commented Jun 17, 2024

Hi @htcfreek, no, I didn't fix it. Also, this issue is completely separate from this PR's objectives. So, we can open a new issue and another PR for the same.

@GhostVaibhav
Copy link
Contributor Author

Hi @htcfreek and @jaimecbernardo
The PR is complete, you can review it whenever free

@htcfreek
Copy link
Collaborator

Hi @htcfreek and @jaimecbernardo
The PR is complete, you can review it whenever free

@GhostVaibhav
I will not have the time before weekend.

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.

Didn't tried the behavior on a loccal build. But had time to look at the test cases.

Comment on lines 22 to 23
[DataRow("HKLM/\"Software\"//test/123", true, @"HKLM\Software", "test/123")]
[DataRow("HKLM/\"Software\"//test\\123", true, @"HKLM\Software", "test\\123")]
Copy link
Collaborator

@htcfreek htcfreek Jun 19, 2024

Choose a reason for hiding this comment

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

Missing a test with the / in a key name. Currently only value names containing a / are tested. And there are also no test cases for mixed inputs (/ and \) and having / in key and value name.

Beeing as creative as possible is great here.

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've added some tests, have a look at them and let me know.

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.

@GhostVaibhav
For my first point we already talked about creating the issue.
The point 3 is working good now and point 2 is working if you use the correct syntax.

But if you type the input without the " then the bug in point 2 with the wrong key splitting still happens.

Input: "HKEY_CURRENT_USER/test/"
- Should return: "HKEY_CURRENT_USER\test/test" (or nothing)
- Should not return: "HKEY_CURRENT_USER\test/test\new"

💡 Idea:
If we can't parse it without " then let's show an error result. The error result can tell the user that in this cas he needs " in the query. It should only be shown on action keyword search.

@GhostVaibhav
Copy link
Contributor Author

GhostVaibhav commented Jun 25, 2024

Hi @htcfreek, are you referring to this?

search3

@htcfreek
Copy link
Collaborator

Hi @htcfreek, are you referring to this?

@GhostVaibhav
Yes.

@GhostVaibhav
Copy link
Contributor Author

Then, it's not a bug. We have a "test" key and a "test/test" key. So,

  1. When writing HKEY_CURRENT_USER/SOFTWARE/test/, we refer to the first one. And
  2. When writing HKEY_CURRENT_USER/SOFTWARE/"test/, we refer to the second one.

Also, we can't recommend the two results, because of the 2 totally different meanings.

@htcfreek
Copy link
Collaborator

Then, it's not a bug. We have a "test" key and a "test/test" key. So,

  1. When writing HKEY_CURRENT_USER/SOFTWARE/test/, we refer to the first one. And
  2. When writing HKEY_CURRENT_USER/SOFTWARE/"test/, we refer to the second one.

Also, we can't recommend the two results, because of the 2 totally different meanings.

  1. No I only have a "test/test" key. The "test" does not exist anymore.
  2. What I mean is: Without " (HKEY_CURRENT_USER/test/) the parsing is wrong and should show the "test/test" key and not the new key in the "test/test" key.

WITHOUT quotation mark
image

WITH quotation mark
image

@GhostVaibhav
Copy link
Contributor Author

GhostVaibhav commented Jun 25, 2024

Hi @htcfreek, some things to consider.

  1. The query HKCU/test/ is converted to HKCU\test\ by the query parser. The result of this query is as given below (as on the latest stable release) -

image

  1. The query HKCU/test/ result on my modified code is as given below -

image

Both the above results are the same. So, that should be the expected behavior. If we want different results, we should probably open another issue regarding the same.

  1. When you type HKCU/"test/, the second / is not converted to \, and therefore the query gets transformed to - HKCU\test/. So, it tries to auto-complete it.

Hope it clears some stuff out.

@htcfreek
Copy link
Collaborator

@GhostVaibhav
So this means we have a general logic error when key names contain a / in it's name.

Does this happen for HKCU\test/ too?

And shouldn't this get fixed by this PR? I am confused and I am sure that users going to open issues for that.

@GhostVaibhav
Copy link
Contributor Author

Hi @htcfreek, some updates on this.

So, the key need not be fully matched to go inside it. On the latest stable release version, here's a screenshot explaining the same -

image

We can see in the above screenshot, that the query hkcu\software\te\ is not fully matching the key name. But, still, it matches.

Also, this shouldn't be included in this PR, because it is a separate broken functionality that needs to be fixed regardless. And, I guess we don't want to club features and fixes in the same PR. For your concern about users going to open issues for that. I will open the issues myself after this PR is closed and probably try fixing it as well.

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.

Now that I know that the two open bug are bugs from stable branch an we open issues for it I am okay with it.

The new code looks good to me.

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.

None yet

3 participants