You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-15 23:10:06 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c1a4ac3e0 | ||
|
|
84578b3b24 | ||
|
|
38fecf55e4 | ||
|
|
284bebf8e7 | ||
|
|
ff1c40049a | ||
|
|
334a52e789 | ||
|
|
0a7001698c |
@@ -1,4 +1,10 @@
|
|||||||
# Code Editor Package for Visual Studio
|
# Code Editor Package for Cursor
|
||||||
|
|
||||||
|
## [2.0.26] - 2025-11-02
|
||||||
|
|
||||||
|
Integration:
|
||||||
|
|
||||||
|
- Add workspace support
|
||||||
|
|
||||||
## [2.0.22] - 2023-10-03
|
## [2.0.22] - 2023-10-03
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,17 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
|||||||
{
|
{
|
||||||
var workspaces = new List<string>();
|
var workspaces = new List<string>();
|
||||||
var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
var cursorStoragePath = Path.Combine(userProfile, "AppData", "Roaming", "cursor", "User", "workspaceStorage");
|
string cursorStoragePath;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR_OSX
|
||||||
|
cursorStoragePath = Path.Combine(userProfile, "Library", "Application Support", "cursor", "User", "workspaceStorage");
|
||||||
|
#elif UNITY_EDITOR_LINUX
|
||||||
|
cursorStoragePath = Path.Combine(userProfile, ".config", "Cursor", "User", "workspaceStorage");
|
||||||
|
#else
|
||||||
|
cursorStoragePath = Path.Combine(userProfile, "AppData", "Roaming", "cursor", "User", "workspaceStorage");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Debug.Log($"[Cursor] Looking for workspaces in: {cursorStoragePath}");
|
||||||
|
|
||||||
if (Directory.Exists(cursorStoragePath))
|
if (Directory.Exists(cursorStoragePath))
|
||||||
{
|
{
|
||||||
@@ -186,6 +196,10 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"[Cursor] Workspace storage directory not found: {cursorStoragePath}");
|
||||||
|
}
|
||||||
|
|
||||||
return workspaces.Distinct().ToArray();
|
return workspaces.Distinct().ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -450,10 +450,29 @@ namespace Microsoft.Unity.VisualStudio.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Process FindRunningCursorWithSolution(string solutionPath) {
|
private Process FindRunningCursorWithSolution(string solutionPath) {
|
||||||
var directory = IOPath.GetDirectoryName(solutionPath);
|
var normalizedTargetPath = solutionPath.Replace('\\', '/').TrimEnd('/').ToLowerInvariant();
|
||||||
var processes = Process.GetProcessesByName("cursor");
|
|
||||||
|
|
||||||
var normalizedTargetPath = directory.Replace('\\', '/').TrimEnd('/').ToLowerInvariant();
|
#if UNITY_EDITOR_WIN
|
||||||
|
// Keep as is for Windows platform since path already includes drive letter
|
||||||
|
#else
|
||||||
|
// Ensure path starts with / for macOS and Linux platforms
|
||||||
|
if (!normalizedTargetPath.StartsWith("/")) {
|
||||||
|
normalizedTargetPath = "/" + normalizedTargetPath;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
var processes = new List<Process>();
|
||||||
|
|
||||||
|
// Get process name list based on different operating systems
|
||||||
|
#if UNITY_EDITOR_OSX
|
||||||
|
processes.AddRange(Process.GetProcessesByName("Cursor"));
|
||||||
|
processes.AddRange(Process.GetProcessesByName("Cursor Helper"));
|
||||||
|
#elif UNITY_EDITOR_LINUX
|
||||||
|
processes.AddRange(Process.GetProcessesByName("cursor"));
|
||||||
|
processes.AddRange(Process.GetProcessesByName("Cursor"));
|
||||||
|
#else
|
||||||
|
processes.AddRange(Process.GetProcessesByName("cursor"));
|
||||||
|
#endif
|
||||||
|
|
||||||
foreach (var process in processes) {
|
foreach (var process in processes) {
|
||||||
try {
|
try {
|
||||||
@@ -461,6 +480,15 @@ namespace Microsoft.Unity.VisualStudio.Editor {
|
|||||||
if (workspaces != null && workspaces.Length > 0) {
|
if (workspaces != null && workspaces.Length > 0) {
|
||||||
foreach (var workspace in workspaces) {
|
foreach (var workspace in workspaces) {
|
||||||
var normalizedWorkspaceDir = workspace.Replace('\\', '/').TrimEnd('/').ToLowerInvariant();
|
var normalizedWorkspaceDir = workspace.Replace('\\', '/').TrimEnd('/').ToLowerInvariant();
|
||||||
|
|
||||||
|
#if UNITY_EDITOR_WIN
|
||||||
|
// Keep as is for Windows platform
|
||||||
|
#else
|
||||||
|
// Ensure path starts with / for macOS and Linux platforms
|
||||||
|
if (!normalizedWorkspaceDir.StartsWith("/")) {
|
||||||
|
normalizedWorkspaceDir = "/" + normalizedWorkspaceDir;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (string.Equals(normalizedWorkspaceDir, normalizedTargetPath, StringComparison.OrdinalIgnoreCase) ||
|
if (string.Equals(normalizedWorkspaceDir, normalizedTargetPath, StringComparison.OrdinalIgnoreCase) ||
|
||||||
normalizedTargetPath.StartsWith(normalizedWorkspaceDir + "/", StringComparison.OrdinalIgnoreCase) ||
|
normalizedTargetPath.StartsWith(normalizedWorkspaceDir + "/", StringComparison.OrdinalIgnoreCase) ||
|
||||||
@@ -479,6 +507,15 @@ namespace Microsoft.Unity.VisualStudio.Editor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string TryFindWorkspace(string directory)
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(directory, "*.code-workspace", SearchOption.TopDirectoryOnly);
|
||||||
|
if (files.Length == 0 || files.Length > 1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return files[0];
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Open(string path, int line, int column, string solution) {
|
public override bool Open(string path, int line, int column, string solution) {
|
||||||
line = Math.Max(1, line);
|
line = Math.Max(1, line);
|
||||||
column = Math.Max(0, column);
|
column = Math.Max(0, column);
|
||||||
@@ -486,6 +523,10 @@ namespace Microsoft.Unity.VisualStudio.Editor {
|
|||||||
var directory = IOPath.GetDirectoryName(solution);
|
var directory = IOPath.GetDirectoryName(solution);
|
||||||
var application = Path;
|
var application = Path;
|
||||||
|
|
||||||
|
var workspace = TryFindWorkspace(directory);
|
||||||
|
workspace ??= directory;
|
||||||
|
directory = workspace;
|
||||||
|
|
||||||
var existingProcess = FindRunningCursorWithSolution(directory);
|
var existingProcess = FindRunningCursorWithSolution(directory);
|
||||||
if (existingProcess != null) {
|
if (existingProcess != null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -1,8 +1,13 @@
|
|||||||
# How to install
|
## How to install
|
||||||
<br>
|
- Unity -> Window -> Package Manager
|
||||||
- Unity->Window->Package Manager<br>
|
- Click "+" at the top left corner
|
||||||
- Click "+" left corner<br>
|
- Add package from git URL
|
||||||
- Add package from git URL<br>
|
- Insert `https://github.com/boxqkrtm/com.unity.ide.cursor.git`
|
||||||
- Insert <code>https://github.com/boxqkrtm/com.unity.ide.cursor.git</code><br>
|
- Add
|
||||||
- Add<br>
|
|
||||||
- Done
|
- Done
|
||||||
|
|
||||||
|
> **Important Notice for Users Updating from Older Versions**
|
||||||
|
> Starting from version **v2.0.24**, the package name has been changed from
|
||||||
|
> `com.unity.ide.cursor` to `com.boxqkrtm.ide.cursor` to prevent potential issues with Unity regarding attribution.
|
||||||
|
> Violating these attribution rules may trigger warnings in Unity.
|
||||||
|
> If you experience errors during the update, please remove the existing package before reinstalling the new one to avoid conflicts.
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
"name": "com.boxqkrtm.ide.cursor",
|
"name": "com.boxqkrtm.ide.cursor",
|
||||||
"displayName": "Cursor Editor",
|
"displayName": "Cursor Editor",
|
||||||
"description": "Cursor editor integration for supporting Cursor as code editor for unity. Adds support for generating csproj files for intellisense purposes, auto discovery of installations, etc.",
|
"description": "Cursor editor integration for supporting Cursor as code editor for unity. Adds support for generating csproj files for intellisense purposes, auto discovery of installations, etc.",
|
||||||
"version": "2.0.24",
|
"version": "2.0.26",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"unityRelease": "25f1",
|
"unityRelease": "25f1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.test-framework": "1.1.9"
|
"com.unity.test-framework": "1.1.9"
|
||||||
},
|
},
|
||||||
"_upm": {
|
"_upm": {
|
||||||
"changelog": "Integration:\n\n- Add support for Cursor"
|
"changelog": "Integration:\n\n- Add workspace support"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user