Repository navigation
feat(desktop): 引用工具窗口对齐 IDEA 查找用法,分组与行预览改由 Core 计算 - #2097
Merged
Merged
Conversation
- 结果按 用法 → 文件 → 用法 三层树展示,文件行带目录和用法数,用法行带行号并加粗命中词 - 右侧预览选中用法所在文件,标出全部用法并选中当前用法,可用分隔条调整宽度、工具栏开关 - 左侧竖排工具栏:重新查找、上一个/下一个用法、全部展开/折叠、显示预览 - 标题栏增加搜索标签(符号名 + 关闭),关闭即清空结果并收起工具窗口 - 抽出 previewAroundRanges 供搜索和引用共用;新增中英词条
- problems_preview.go 原有一份与 source_preview.go 逐行重复的只读预览(加载、安装、绘制),改为调用 showSourcePreview / sourcePreviewPane,只保留取选中诊断的逻辑 - 新增 TestProblemsPreviewFollowsTheSelectedDiagnostic 覆盖预览跟随选中诊断、不打开编辑器、读不到文件时显示原因 - references-pane 功能矩阵补充 IDEA 式布局说明与证据;新增改动前后截图
- 新增 core.ReferencesQuery / ReferencesLines,桥接 Core 的 lsp.references.query、 lsp.references.lines;桌面端删掉 Go 里的分组排序、可见行投影、选中转移、 上一个/下一个用法和行裁剪,只保留折叠状态、选中键、读文件与绘制 - 文件分组改为项目视图的自然文件名顺序;用法行文本在后台由 Core 裁剪后回填 - workspace.search 返回 previewRanges,查找结果和随处搜索不再各自裁剪行 - 编辑器右键菜单“查找引用”改为“查找用法”(仍是 Shift+F12),右键点在选区外 时查的是被点的词,补单元测试 - PINNED_CORE_REVISION 固定 Core #80 分支提交 81a6ecf,合入后改为 main 的合并提交 - 更新 references-pane 功能矩阵 Refs #2096, Lithe-IDEA/Lithe-core-rust#80
在 TestVisualReferencesToolWindow 里右键点 absSelf,截取编辑器菜单(查找用法 Shift+F12), 提交深色中文和浅色英文两张;功能矩阵记录这项无头截图。 Refs #2096
xiaoyumuxi
marked this pull request as ready for review
November 17, 2026 11:16
23 of 25 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
lsp.references.query、lsp.references.lines、搜索结果的previewRanges)布局对齐的需求是维护者直接用 IDEA 查找用法窗口的截图提出的,没有单独的功能 Issue。#2096 要求把引用结果的分组、排序、树投影和行预览迁入 Core,本 PR 连同 Core #80 一起完成。合入顺序:先合 Core #80,再把本 PR 的
PINNED_CORE_REVISION换成 #80 在 main 上的合并提交,最后合本 PR。PR 类型 / Type
改动说明 / What changes
背景 / Why
查找用法(Find Usages)的结果原来是一张平铺列表:每个文件一行粗体标题,下面是用法行。没有工具栏,没有搜索标签,也看不到用法所在的上下文,只能逐个点开。用户希望它和 IntelliJ IDEA 的查找用法窗口一样:
结果的分组、排序、树投影和行预览裁剪原本都写在 Go 界面层,搜索结果和随处搜索也各有一份裁剪行的代码。按逻辑归属规则,这些规则改由 Rust Core 计算,桌面端只保留状态、读文件和绘制(#2096)。
改动 / Changes
引用工具窗口布局(
references_view.go、shell_view.go)editor.references.close)。ui.Tree,结构是根节点“用法 · N 个结果”→ 文件节点 → 用法行。行号加去掉缩进的源码行,用法本身以编辑器字体加粗。Viva 的Bold()只是 semibold,在等宽字体里几乎看不出,所以这里用Weight(gfx.WeightBold)。ui.Splitter分隔。树初始宽 380,树和预览的最小宽度分别是 180 和 200。editor.references.open,沿用原有动作名);在文件节点上则是展开或收起。分组、树行、步进和行预览改由 Core 计算
Core 的规则和 fixture 见 Lithe-IDEA/Lithe-core-rust#80。
desktop/internal/core/references.go(新):桥接两个 Core 命令。Client.QueryReferences调用lsp.references.query。fileKey、显示路径、行、列),以及折叠的根节点和文件、选中键。groups,带文件名、目录和用法索引。rows:每行带行键root/file:<fileKey>/usage:N、深度、展开状态,选中该行时预览的用法shows,以及树序上的前后用法previous/next。selected/selectedRow。Client.ReferenceLines调用lsp.references.lines。它把用法所在行去掉缩进;用法离行首较远时截掉前面并加省略号,最多 240 字节;按 UTF-16 返回高亮范围。相同的行文本只传一次。workbench.Kernel接口加上这两个方法。references.go:newUsageGroup)、整数行键(fileKey/usageKey)、可见行投影(layoutRows)、折叠与选中转移(toggle/setExpanded/selectedUsage),以及行裁剪(referenceLineOf)。layoutReferences在显示结果、展开或收起、步进、选中用法时请求 Core,toggleReference/expandReferences/selectUsage只改折叠集合和选中键。shownTarget/stepTarget直接读 Core 给的shows/previous/next。loadReferenceLines:已打开文件的行从编辑器读取,未打开的文件在后台读取(每个文件最多 2 MiB),再在后台交给 Core 裁剪,回到窗口线程后填入。行文本因此异步出现:先显示行号,随后补上文本。workspace.search带includeContentRanges时,返回 Core 按同一规则裁好的preview和新增的previewRanges(desktop/internal/core/workspace.go加字段)。search_view.go和search_everywhere_view.go直接绘制这两个字段。search.go的searchPreviewLine、previewAroundRanges和search_everywhere_view.go的trimHighlightedLine。查找用法入口(
pluginsemantics.go、pluginsemantics_view.go、editor_menu.go)definitionState.references字段,以及definitionPopupTitle的引用分支。presentDefinitionTargets的单个结果直接跳转,不再需要区分引用。共享源码预览(
source_preview.go、problems_preview.go、problems.go、problems_view.go)sourcePreview。problemsPreview实现(约 150 行),本 PR 一并改成调用sourcePreview,删除重复代码。Problems 的行为不变:不抢键盘焦点、不写文件、已打开文档显示未保存的内容。文案(
shared/i18n/)desktop.editorMenu.findUsages(查找引用 → 查找用法),以及空状态提示desktop.references.empty里的同一个词。shared.generated.go。固定 Core 版本(
scripts/desktop/build-desktop-core.sh)PINNED_CORE_REVISION现在固定为 Core Fix staging/unstaging of files in changes group checkbox #80 分支上的提交81a6ecf(基于 Core main788e61e),注释里写明了包含的命令。Fix staging/unstaging of files in changes group checkbox #80 合入后要换成 main 上的合并提交(见“不在本 PR 范围内”)。测试
desktop/internal/core/references_test.go(新):经真实 Core 跑references-query-v1.json(7 个用例)和references-lines-v1.json(4 个用例)这两份共享 fixture,桥接类型与 Core 输出的 JSON 不一致时失败。fixture 覆盖了:references_test.go(新):pluginsemantics_test.go:TestEditorMenuFindUsagesAsksAtTheRightClickedPlace:光标在别处时右键点另一个位置,再点菜单的“查找用法”,断言请求的位置是点击处。problems_test.go:新增TestProblemsPreviewFollowsTheSelectedDiagnostic,覆盖改用共享预览后的跟随选中、不打开文档、读不到文件时报错。references_visual_test.go(新,vivahead && lithevisual):功能矩阵与截图
shared/platform-feature-matrix/features/references-pane.json:pending。docs/assets/references-find-usages/{before,after}/:改动前后对照截图,以及右键菜单截图。不在本 PR 范围内 / Out of scope
PINNED_CORE_REVISION换成合并提交,并改写注释里那一行。这一步在本 PR 标记 ready 之前完成,不另开单。类型专属:feat
多平台对齐
platform-specific),理由:桌面端的改动全部在 macOS 与 Windows 共用的 Viva 代码
desktop/internal/里,没有平台分支;规则在两端共用的 Rust Core 里。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/references-pane.json:两端的实现状态和验证状态、证据路径、owner、验证动作都如实填写;没有运行验证的保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkilltextDocument/references和插件的语义提供者,只改了结果的分组和展示;workspace.search只是多返回一个字段UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… ../scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' -run TestVisualReferencesToolWindow ./internal/workbench/8960dddabsSelf查找用法,再在编辑器里右键点absSelfdocs/assets/references-find-usages/9f1611609上用同一场景截取。编辑器右键菜单(右键点
absSelf,状态栏 5:4 表明光标已移到点击处):统一日志系统 / Structured logging
a.performed(...)记录,写的是 Core 已声明的app.action.performed事件,动作名只是action字段的值:editor.references.rerun、editor.references.previous、editor.references.next、editor.references.preview、editor.references.close(editor.references.open原本就有)。operationFailed/backgroundFailed:app.notification.operation_failed(references_query),并弹出错误通知;app.background.operation_failed(references_lines)。print或直接写 stderr。界面文案 / i18n
shared/i18n/补齐中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果,没有手改生成文件;Viva 代码通过desktop/internal/i18n/的接口读取node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
previewRanges。references-query-v1.json和references-lines-v1.json两份 fixture,桌面端桥接测试直接读取。性能与内存 / Performance and memory
maxReferenceTargets)。lsp.references.lines都在a.background里执行。lsp.references.query是进程内的 Core 调用,只在显示结果、展开或收起、步进、选中用法这些用户操作时同步调用一次。它不在每帧调用,输入最多 500 个位置,并受kernelCallTimeout限制。ui.Splitter,和 Problems、项目树一样,拖动时不触发文件读取或 Core 调用。设置 / Settings
N/A:没有新增或修改设置项。“显示预览”只是工具窗口里的一个开关,不持久化。
插件契约 / Plugin contract
N/A:没有改插件契约(
shared/plugins/)、能力版本、插件函数协议或宿主方法。Core #80 新增的是宿主内部的 Core 命令,PINNED_CORE_REVISION已升到包含它们的提交。发行包与资源 / Bundle and resources
N/A:没有新增运行时资源、缓存或下载物。已运行
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,结果通过。无用代码与重构 / Dead code and refactoring
definitionState.references、definitionPopupTitle的引用分支。ui.ListState、starts/rows/rowAt、文件标题行drawReferenceHeader。newUsageGroup、layoutRows、toggle、setExpanded、selectedUsage、referenceLineOf、searchPreviewLine、previewAroundRanges、trimHighlightedLine。problemsPreview。refactor标签的 Issue:[Feature] 引用(查找用法)结果的按文件分组、排序和树投影下沉到 Core,与 Problems 的 QueryProblems 一致 #2096(本 PR 关闭)。Problems 原有的problemsPreview是sourcePreview的重复实现,接入共享预览时一并删除,并补了TestProblemsPreviewFollowsTheSelectedDiagnostic覆盖验证 / Verification
桌面端测试链接的是 Core #80 的分支检出(
LITHE_CORE_RUST_DIR指向81a6ecf),与PINNED_CORE_REVISION一致。cargo test --locked -p lithe-core -- lsp_policy projectcargo test --locked -p lithe-lsp-policy -p lithe-text -p lithe-project、clippy-D warnings、cargo fmt --check、注释规范、平台测试规范、verify-docs.mjsdesktop-go.sh test -count=1 ./internal/core/ ./internal/workbench/... ./internal/i18n/ ./internal/shortcuts/(8960ddd)TestVisualReferencesToolWindow(vivahead && lithevisual,4 组外观 × 引用窗口和右键菜单)gofmt -l、desktop-go.sh vet -tags 'vivahead lithevisual' ./internal/workbench/ ./internal/core/.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/maintest-stability-macos.sh --package ./internal/core --package ./internal/workbench --filter 'Reference|FindUsages|Search|Preview'TestEditorMenuFindUsagesAsksAtTheRightClickedPlace);超过 1 s 的 3 个是过滤词顺带匹配到的 Git 测试,本 PR 没有改动node scripts/i18n/verify-app-language-localization.mjsnode scripts/i18n/generate-i18n.mjs --check./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/desktop/verify/verify-runtime-bundle-immutability.shdevelop-lithe第三节插件归属自查未能执行的检查和原因:
pending。提交前确认 / Final checks
main创建;目标分支:main。分支基于origin/main05f9958,之后 main 又有新提交;标记 ready 前,与换 Core 固定版本一起合入最新 main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图