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

Open script with SystemDefault Editor #2

Closed
wants to merge 1 commit into from
Closed

Open script with SystemDefault Editor #2

wants to merge 1 commit into from

Conversation

Neikice
Copy link

@Neikice Neikice commented Sep 1, 2016

OpenFileAtLineExternal sometimes do not openfile with SystemDefault Editor.

Copy link
Contributor

@Kalmalyzer Kalmalyzer left a comment

Choose a reason for hiding this comment

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

I have done some tests with Unity 5.5 on Windows.

Usually, UberLogger's StackTrace code will create its own stacktrace. It will then have absolute paths.
However, there are some code paths (rarely executed) in which UberLogger will generate relative paths, i,e. "Assets..." or "Assets/...".

For absolute paths, OpenFileAtLineExternal() works fine (files open in Visual Studio) but for relative paths this will attempt to open the files in MonoDevelop.

It appears that AssetDatabase.OpenAsset() will open with the right editor. Is that the purpose of this change? (Otherwise I am unsure about the purpose)

If so, I would suggest to check whether the path is absolute or relative and handle both kinds. I.e. both C:...\Assets\Subdir\MyFile.cs and Assets\Subdir\MyFile.cs should result in Subdir/MyFile.cs after relativization.

@Kalmalyzer
Copy link
Contributor

Some test results for completeness. Run on Windows:

UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal("c:\\Temp\\UnitHighlight.txt", 4) will open in the external editor that the user has chosen.

UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal("c:/Temp/UnitHighlight.txt", 4) will open in the external editor that the user has chosen.

UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal("Assets\\Scripts\\FileInProject.cs", 4) does not work.

UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal("Scripts\\FileInProject.cs", 4) does not work.

UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal("Assets/Scripts/FileInProject.cs", 4) does not work.

AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath<TextAsset>("Assets/Scripts/FileInProject.cs"), 4) will open in the external editor that the user has chosen.

AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath<TextAsset>("Assets\\Scripts\\FileInProject.cs"), 4) will open in the external editor that the user has chosen.

AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath<TextAsset>("C:\\MyProject\\Assets\\Scripts\\FileInProject.cs"), 4) does not work.

I am still looking for a test case which will reliably open files with the wrong editor...

@Kalmalyzer
Copy link
Contributor

I believe that with #25 the OpenFileAtLineExternal() call will open the SystemDefault editor as intended. If that is the case, this PR is no longer necessary.

@bbbscarter bbbscarter closed this Jun 19, 2017
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.

3 participants