AvinZarlez / unity-tools

A Visual Studio Code Extension to provide some tools for Unity development
https://marketplace.visualstudio.com/items?itemName=Tobiah.unity-tools
MIT License
31 stars 8 forks source link

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

Open MiCkSoftware opened 4 years ago

MiCkSoftware commented 4 years ago

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):

AvinZarlez commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Interesting!

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

AvinZarlez commented 4 years ago

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 commented 4 years ago

Debugging to do:

MiCkSoftware commented 4 years ago

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

AvinZarlez commented 4 years ago

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 commented 4 years ago

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

MiCkSoftware commented 4 years ago

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

MiCkSoftware commented 4 years ago

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

AvinZarlez commented 4 years ago

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:

Other general weird debugging ideas

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

lg-montoya commented 3 years ago

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?