dsh-vscode-mode 0.1.55 → 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -285,6 +285,10 @@ V8 展开约 10×)。会话越多越大,启动内存越高,可能冲爆堆
|
|
|
285
285
|
`Editor/com.dsh.editor.asmdef`,`"unity": "2019.4"` 基线;机制参照 com.unity.ide.traeCN 的
|
|
286
286
|
`IExternalCodeEditor`:虚拟安装 `dsh-editor://vscode-mode`,`OpenProject` → `Application.OpenURL(深链)`,
|
|
287
287
|
不需要本地可执行文件,不生成 csproj)。
|
|
288
|
+
- **打开过滤**:Unity 对双击的任何资产(含 prefab/scene)都会回调 `OpenProject`;仅文本/代码类扩展名
|
|
289
|
+
(白名单 + Project Settings 用户自定义扩展 `EditorSettings.projectGenerationUserExtensions`)交 DSH
|
|
290
|
+
打开,其余返回 `false` 交还 Unity 原生处理(双击预制体进预制体模式、双击场景开场景),对齐官方
|
|
291
|
+
`DefaultExternalCodeEditor` 行为。
|
|
288
292
|
- **一键安装/更新**:设置页登记 Unity 项目根(校验 `Assets` + `ProjectSettings` 特征)后,点「安装/更新」把包源
|
|
289
293
|
整目录复制为 `<项目>/Packages/com.dsh.editor`(Unity **内嵌包**自动发现,无需改 manifest.json);更新 = 整目录
|
|
290
294
|
替换,列表显示已装版本与「可更新」徽标;目标已存在且 `package.json` name 不是 `com.dsh.editor` 时拒绝覆盖。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vscode-mode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"description": "DSH 上的类 VSCode 编码体验:Monaco 编辑器(文件页签/QuickOpen/状态栏,可驻 dsh-better-sidebar 侧边栏与对话同屏)+ Agent 编辑差异审查(整文件差异/采纳/拒绝/归档/回滚)+ 语言服务器(LSP)智能(跳转定义/引用/hover/大纲 + VSIX 扩展市场安装),状态持久化到工作区旁车",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
// 回退 Application.OpenURL 深链。移交全程后台线程(不阻塞编辑器主线程),
|
|
7
7
|
// 回退开浏览器经 EditorApplication.delayCall 切回主线程。
|
|
8
8
|
// 深链契约见插件 src/shared/externalOpen.ts(edrvOpen/edrvPaths/edrvLine/edrvColumn)。
|
|
9
|
+
// 过滤:Unity 对双击的任何资产(含 prefab/scene)都会回调 OpenProject;仅放行文本/代码类
|
|
10
|
+
// 扩展名(白名单 + Project Settings 用户扩展),其余返回 false 交还 Unity 原生处理
|
|
11
|
+
// (双击预制体进预制体模式、双击场景开场景),对齐 DefaultExternalCodeEditor 行为。
|
|
9
12
|
// 作者 ddj 2026-09-08
|
|
10
13
|
using System;
|
|
11
14
|
using System.IO;
|
|
@@ -25,7 +28,7 @@ namespace Dsh.EditorIntegration
|
|
|
25
28
|
private const string VirtualPath = "dsh-editor://vscode-mode";
|
|
26
29
|
private const string BaseUrlPref = "DshEditor.BaseUrl";
|
|
27
30
|
private const string DefaultBaseUrl = "http://127.0.0.1:3080";
|
|
28
|
-
private const string DshVersion = "0.2.
|
|
31
|
+
private const string DshVersion = "0.2.4";
|
|
29
32
|
internal const string VersionText = DshVersion;
|
|
30
33
|
|
|
31
34
|
static DshCodeEditor()
|
|
@@ -96,11 +99,54 @@ namespace Dsh.EditorIntegration
|
|
|
96
99
|
public bool OpenProject(string path, int line, int column)
|
|
97
100
|
{
|
|
98
101
|
// Open C# Project(Assets 菜单)传入空路径:视为打开 Unity 项目根(按文件夹规则路由)
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
if (string.IsNullOrEmpty(path))
|
|
103
|
+
{
|
|
104
|
+
BeginOpen(ProjectRoot(), line, column);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 非文本/代码文件(prefab/scene/asset/模型/纹理等)不交 DSH:返回 false 交还 Unity 原生
|
|
109
|
+
// 处理(双击预制体进预制体模式、双击场景开场景),否则 Unity 双击资产会被本编辑器劫持。
|
|
110
|
+
var absPath = ResolveAbsolute(path);
|
|
111
|
+
if (!IsSupportedFile(absPath)) return false;
|
|
112
|
+
|
|
113
|
+
BeginOpen(absPath, line, column);
|
|
101
114
|
return true;
|
|
102
115
|
}
|
|
103
116
|
|
|
117
|
+
/// <summary>文本/代码类扩展名白名单:官方 DefaultExternalCodeEditor 支持集 + 常见文本/脚本类型。</summary>
|
|
118
|
+
private static readonly string[] SupportedExtensions =
|
|
119
|
+
{
|
|
120
|
+
"cs", "txt", "log", "json", "xml", "md", "yaml", "yml", "meta", "ini", "csv", "tsv",
|
|
121
|
+
"lua", "py", "js", "jsx", "ts", "tsx", "css", "html", "htm", "sql",
|
|
122
|
+
"sh", "bat", "ps1", "c", "h", "cpp", "hpp", "cc",
|
|
123
|
+
"shader", "compute", "cginc", "hlsl", "glslinc", "template", "raytrace",
|
|
124
|
+
"asmdef", "asmref", "uxml", "uss"
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/// <summary>
|
|
128
|
+
/// 判定文件是否支持交 DSH 打开:白名单命中,或 Unity Project Settings 用户自定义扩展命中。
|
|
129
|
+
/// @author ddj 2026年09月22号
|
|
130
|
+
/// </summary>
|
|
131
|
+
/// <param name="absPath">资产绝对路径</param>
|
|
132
|
+
/// <returns>true = 支持 DSH 打开;false = 交还 Unity 原生处理</returns>
|
|
133
|
+
private static bool IsSupportedFile(string absPath)
|
|
134
|
+
{
|
|
135
|
+
var ext = Path.GetExtension(absPath);
|
|
136
|
+
if (string.IsNullOrEmpty(ext)) return false;
|
|
137
|
+
ext = ext.Substring(1).ToLowerInvariant();
|
|
138
|
+
if (Array.IndexOf(SupportedExtensions, ext) >= 0) return true;
|
|
139
|
+
|
|
140
|
+
var userExts = EditorSettings.projectGenerationUserExtensions;
|
|
141
|
+
if (userExts == null) return false;
|
|
142
|
+
foreach (var userExt in userExts)
|
|
143
|
+
{
|
|
144
|
+
if (string.Equals(userExt, ext, StringComparison.OrdinalIgnoreCase)) return true;
|
|
145
|
+
if (string.Equals(userExt, "." + ext, StringComparison.OrdinalIgnoreCase)) return true;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
|
|
104
150
|
/// <summary>
|
|
105
151
|
/// 后台线程执行移交/回退(不阻塞编辑器主线程)。
|
|
106
152
|
/// ⚠️ EditorPrefs 仅主线程可读:baseUrl 必须在主线程(BeginOpen 调用点)读好后闭包捕获,
|
|
@@ -29,5 +29,7 @@
|
|
|
29
29
|
- 本包为虚拟外部编辑器:不需要本地可执行文件。打开优先走「移交」:POST 到 DSH host 的
|
|
30
30
|
`edrv.external.handoff`,已打开页面 3s 轮询领取并执行打开规则(文件夹/文件的智能路由见插件 README);
|
|
31
31
|
无活跃页面或 2s 未领取时回退 `Application.OpenURL` 深链。移交在后台线程执行,不阻塞编辑器。
|
|
32
|
+
- 仅文本/代码类文件(扩展名白名单 + Project Settings 用户自定义扩展)交 DSH 打开;双击预制体、
|
|
33
|
+
场景、模型、纹理等资源不受影响,仍由 Unity 原生处理(预制体编辑模式、场景打开等)。
|
|
32
34
|
- 编辑器内查看任意绝对路径文件;保存受 DSH 会话沙箱策略约束(工作区外保存会被拒绝,属预期安全行为)。
|
|
33
35
|
- 卸载:删除 `<项目>/Packages/com.dsh.editor` 目录,并在 External Script Editor 换回其他编辑器。
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"name": "com.dsh.editor",
|
|
3
3
|
"displayName": "DSH 文件编辑",
|
|
4
4
|
"description": "DSH(dsh-vscode-mode)编辑器集成:把「DSH 文件编辑」注册为 Unity 外部脚本编辑器,双击脚本或 Console 报错跳转时,优先把打开请求移交已打开的 DSH 页面就地执行(不重复开新页),无活跃页面时回退经默认浏览器深链打开对应文件与行列。支持从 DSH 设置页一键安装/更新(内嵌包方式,无需手动改 manifest.json)。",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.4",
|
|
6
6
|
"unity": "2019.4"
|
|
7
7
|
}
|