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

[BUG] Open documentation for selection goes to wrong page #60

Open
MiCkSoftware opened this issue Feb 16, 2020 · 15 comments
Open

[BUG] Open documentation for selection goes to wrong page #60

MiCkSoftware opened this issue Feb 16, 2020 · 15 comments
Assignees
Labels

Comments

@MiCkSoftware
Copy link

MiCkSoftware commented Feb 16, 2020

Describe the bug
Extension always opens file:///Applications/Unity/Documentation/en/ScriptReference/30_search.html

To Reproduce
Steps to reproduce the behavior:

  1. Go to a c# files
  2. Right-Click on a class
  3. Select 'Unity Tools: Open documentation for selection'
  4. file:///Applications/Unity/Documentation/en/ScriptReference/30_search.html opens with no params

config
Extension is configured for local documentation : "Applications/Unity/Documentation/en/ScriptReference"
Local documentation viewer = "safari"

Expected behavior
Help for the selected class should open. Eg:
file:///Applications/Unity/Documentation/en/ScriptReference/30_search.html?q=GameObject

VSCode (please complete the following information):

  • OS: OS X
  • Version Mojave
@AvinZarlez
Copy link
Owner

AvinZarlez commented Feb 18, 2020

To clarify, the extension searches for what you have highlighted. If you don't have something highlighted, it takes you to the blank search page.

Can you, between your step 1 and 2, highlight "GameObject" and then right click and search. Does it work then?

If that is the case:
I think I might need to add a feature to see if I can auto highlight/search the right click selected word rather than open a blank search page. That would probably be a useful feature either way.

If you actually are highlighting a word, and it still doesn't search correctly:
This is a bug. Let me know if that is the case, and I can figure out what might be happening.

@MiCkSoftware
Copy link
Author

Hi!
Thanks for reaching me back.
I Confirm I am highlighting a word and that this word is not passed on to safari. Even ?q= is missing.

Cheers!
Mick

@AvinZarlez
Copy link
Owner

Interesting!

Is that also the case if you trigger via Command Palette (⇧⌘P) as well?

@AvinZarlez
Copy link
Owner

You should be also able to trigger via Command Palette with nothing highlighted, and it will prompt you to enter some text. You should be able to enter "Test" or whatever you want, and search.

If that doesn't work, I wonder if this is a bug with passing params like ?q=something into Safari via the open method. I had not tested that since I don't have easy access to a Mac.

@AvinZarlez
Copy link
Owner

AvinZarlez commented Feb 18, 2020

Debugging to do:

  • Try to trigger via command palette rather than right-click
  • Does search work as expected via another browser? (ex. Firefox)
  • Does search work as expected when not searching local documentation?

@MiCkSoftware
Copy link
Author

command palette same issue
with chrome nothing happens at all
with online doc it works like a charm

@AvinZarlez
Copy link
Owner

Did you enter "chrome" or "Google Chrome"? If nothing happens at all, probably just not finding the chrome app.

One of the issues with searching local documentation is needing to pass in the browser. This was because of issues I ran into that general "open url" commands were parsing out the ~?=

Hence why I'm suspecting it might be safari that's doing that automatically. But I could be wrong.

@AvinZarlez
Copy link
Owner

You might also want to try "/Applications/Google Chrome.app"

@MiCkSoftware
Copy link
Author

Chrome do open with full path in settings (/Applications/Google Chrome.app)
But then again, it takes no parameter.

@MiCkSoftware
Copy link
Author

Also tried this setting with no luck:
/usr/bin/open -a Safari

@AvinZarlez
Copy link
Owner

Interesting, so like Safari, it opens but the parameters are either being parsed or not assigned.

I think this is related to the main problems of #21 that file:/// is not designed to take parameters like HTTP is. The whole setting viewer thing was a hack in itself.

Tobiah's To-Do:

  • Get access to a Mac to test
  • Use debugging and/or change "Base" URL to ensure the extension is correctly sending the parameters in the first place.
  • Check if open works with parameters on mac without setting app

Other general weird debugging ideas

  • What happens if localDocumentationViewer is blank? (May need to be set to something non-null like a space " " to override the default value of "firefox")
  • Does firefox work, where chrome/safari don't?

Overall, it may require a rewrite of how local documentation works to do something like suggested here: https://stackoverflow.com/questions/35557531/parameters-are-removed-when-opening-local-url-in-default-browser

Generating an HTML page and loading from that, which redirects to the correct URL with parameters.

@MiCkSoftware
Copy link
Author

Hi,

I've investigated a little more and open will not accept URL params: https://stackoverflow.com/questions/9533720/open-a-web-page-with-url-params-from-the-command-line-locally

this works:
osascript -e 'tell application "Safari" to open location "file:///Applications/Unity/Documentation/en/ScriptReference/30_search.html?q=GameObject"'

Cheers!
Mick

@AvinZarlez
Copy link
Owner

I think that further cements I need to do a system where it launches a local html page that has been prewritten to automatically redirect. Then I can remove the need to pick the browser entirely, and remove open as a dependency for the project

@MiCkSoftware
Copy link
Author

👌let me know when you need me to test it.

@lg-montoya
Copy link

Hello

I just started using your extension (great tool btw) v1.2.12 and noticed the same behaviour (appended "/30_search.html").

I'm on OSx Catalina 10.15.7, Unity Editor v2019.4.18f1, VS Code Version: 1.52.1., Safari Version 14.0.1

In my VSCode settings file I have:

"unity-tools.localDocumentationPath" : "Applications/Unity/Hub/Editor/2019.4.18f1/Documentation/en/ScriptReference",
"unity-tools.localDocumentationViewer": "safari"

TO reproduce behaviour I highlight a method in a cs file and cmd+' (shortcut key ... same result with right-click search).

Any luck on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants