4 Commits

Author SHA1 Message Date
boxqkrtm
8bf674e510 fix: change default value of ReuseExistingWindowKey to false 2025-11-02 14:32:38 +09:00
boxqkrtm
22d40e0e16 refactor: make ReuseExistingWindowKey internal for better encapsulation 2025-11-02 14:31:29 +09:00
boxqkrtm
c14987c13b chore: remove too verbose log 2025-11-02 14:24:15 +09:00
boxqkrtm
866c5bfc20 feat: Add Multiple or Single Cursor Instance Options 2025-11-02 14:21:39 +09:00
2 changed files with 4 additions and 25 deletions

View File

@@ -584,12 +584,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
var application = Path;
var workspace = TryFindWorkspace(directory);
// Use version-compatible null-coalescing for Unity 2019.4 (C# 7.3) support
#if UNITY_2020_2_OR_NEWER
workspace ??= directory;
#else
workspace = workspace ?? directory;
#endif
directory = workspace;
if (EditorPrefs.GetBool(ReuseExistingWindowKey, false))

View File

@@ -44,11 +44,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
[InitializeOnLoadMethod]
static void LegacyVisualStudioCodePackageDisabler()
{
#if UNITY_2021_1_OR_NEWER
// disable legacy Visual Studio Code packages
var editor = CodeEditor.Editor.GetCodeEditorForPath("code.cmd");
#else
var editor = CodeEditor.CurrentEditor;
#endif
if (editor == null)
return;
@@ -141,7 +138,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
var newReuseWindow = EditorGUILayout.Toggle(new GUIContent("Reuse existing Cursor window", "When enabled, opens files in an existing Cursor window if found. When disabled, always opens a new window."), reuseWindow);
if (newReuseWindow != reuseWindow)
EditorPrefs.SetBool(VisualStudioCursorInstallation.ReuseExistingWindowKey, newReuseWindow);
EditorGUILayout.Space();
}
@@ -229,9 +226,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
var editorPath = CodeEditor.CurrentEditorInstallation;
// Performance optimization: Use cached installation lookup instead of discovering every time
if (!TryGetVisualStudioInstallationForPath(editorPath, lookupDiscoveredInstallations: true, out var installation))
{
if (!Discovery.TryDiscoverInstallation(editorPath, out var installation)) {
Debug.LogWarning($"Visual Studio executable {editorPath} is not found. Please change your settings in Edit > Preferences > External Tools.");
return false;
}
@@ -243,8 +238,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
if (!IsProjectGeneratedFor(path, generator, out var missingFlag))
Debug.LogWarning($"You are trying to open {path} outside a generated project. This might cause problems with IntelliSense and debugging. To avoid this, you can change your .csproj preferences in Edit > Preferences > External Tools and enable {GetProjectGenerationFlagDescription(missingFlag)} generation.");
// Performance optimization: Only sync if solution doesn't exist
var solution = GetOrGenerateSolutionFileIfNeeded(generator);
var solution = GetOrGenerateSolutionFile(generator);
return installation.Open(path, line, column, solution);
}
@@ -313,15 +307,5 @@ namespace Microsoft.Unity.VisualStudio.Editor
generator.Sync();
return generator.SolutionFile();
}
// Performance optimization: Only sync if solution file doesn't exist
private static string GetOrGenerateSolutionFileIfNeeded(IGenerator generator)
{
if (!generator.HasSolutionBeenGenerated())
{
generator.Sync();
}
return generator.SolutionFile();
}
}
}