dsh-gufa-code 1.3.91 → 1.3.92

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/client.js CHANGED
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
18
  /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
- G.BUILD = '1.3.91'
19
+ G.BUILD = '1.3.92'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -9793,7 +9793,16 @@ function activeSessionId() {
9793
9793
  const text = model.getValueInRange(selection);
9794
9794
  if (!text) return null;
9795
9795
  const rawPath = model.uri && model.uri.path ? String(model.uri.path) : "";
9796
- const path = decodeURIComponent(rawPath.replace(/^\//, ""));
9796
+ const absolute = decodeURIComponent(rawPath.replace(/^\//, ""));
9797
+ if (absolute === "") return null;
9798
+ /* gufa 的 model URI 是项目绝对路径;引用 chip 需要项目相对路径 */
9799
+ let path = absolute;
9800
+ try {
9801
+ const root = typeof G.projectRoot === "string" ? String(G.projectRoot).replace(/\/+$/, "") : "";
9802
+ const rootNoSlash = root.replace(/^\//, "");
9803
+ if (root !== "" && absolute.startsWith(root + "/")) path = absolute.slice(root.length + 1);
9804
+ else if (rootNoSlash !== "" && absolute.startsWith(rootNoSlash + "/")) path = absolute.slice(rootNoSlash.length + 1);
9805
+ } catch (_) {}
9797
9806
  if (path === "") return null;
9798
9807
  const startLine = Math.min(selection.startLineNumber, selection.endLineNumber);
9799
9808
  const endLine = Math.max(selection.startLineNumber, selection.endLineNumber);
@@ -7,8 +7,8 @@
7
7
  <key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
8
8
  <key>CFBundleExecutable</key><string>gufa-float</string>
9
9
  <key>CFBundlePackageType</key><string>APPL</string>
10
- <key>CFBundleShortVersionString</key><string>1.3.91</string>
11
- <key>CFBundleVersion</key><string>1.3.91</string>
10
+ <key>CFBundleShortVersionString</key><string>1.3.92</string>
11
+ <key>CFBundleVersion</key><string>1.3.92</string>
12
12
  <key>LSUIElement</key><true/>
13
13
  <key>NSHighResolutionCapable</key><true/>
14
14
  <key>NSPrincipalClass</key><string>NSApplication</string>
@@ -37,6 +37,7 @@
37
37
  - 成功复制/插入/拖动/跳转一律不弹 toast(用户明确讨厌成功提示),只有失败才提示;toast 复用 `G.refToast`。
38
38
  - 古法 IDE 内点击引用 chip:优先 `G.bus.emit('editor:open-at')` 打开自己的 Monaco 标签,再 `selectRange` 选中行范围;不要依赖 DSH 侧边栏资源路由。
39
39
  - 行范围引用格式 `@path Lx-Ly`;chip 标签里存路径+行号用于点击定位,`localStorage` key 使用 `gufa-code.refs.v1`。
40
+ - **model URI 是项目绝对路径,引用 chip 必须转成项目相对路径**(`G.projectRoot` 前缀剥离),否则点击 chip 会走 `fs.read` 绝对路径并报「路径不存在」;这个坑 1.3.92 已修。
40
41
 
41
42
  ## 1. 弹窗/菜单层级:只有一个正确做法(反复踩过多次,最终定案)
42
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.91",
3
+ "version": "1.3.92",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -215,7 +215,16 @@ function activeSessionId() {
215
215
  const text = model.getValueInRange(selection);
216
216
  if (!text) return null;
217
217
  const rawPath = model.uri && model.uri.path ? String(model.uri.path) : "";
218
- const path = decodeURIComponent(rawPath.replace(/^\//, ""));
218
+ const absolute = decodeURIComponent(rawPath.replace(/^\//, ""));
219
+ if (absolute === "") return null;
220
+ /* gufa 的 model URI 是项目绝对路径;引用 chip 需要项目相对路径 */
221
+ let path = absolute;
222
+ try {
223
+ const root = typeof G.projectRoot === "string" ? String(G.projectRoot).replace(/\/+$/, "") : "";
224
+ const rootNoSlash = root.replace(/^\//, "");
225
+ if (root !== "" && absolute.startsWith(root + "/")) path = absolute.slice(root.length + 1);
226
+ else if (rootNoSlash !== "" && absolute.startsWith(rootNoSlash + "/")) path = absolute.slice(rootNoSlash.length + 1);
227
+ } catch (_) {}
219
228
  if (path === "") return null;
220
229
  const startLine = Math.min(selection.startLineNumber, selection.endLineNumber);
221
230
  const endLine = Math.max(selection.startLineNumber, selection.endLineNumber);