Repository navigation
fix(desktop): Hover 弹窗渲染 Markdown 并贴近指针,移向弹窗时不再收回 - #1877
Merged
Merged
Conversation
- Hover 内容按 Markdown 渲染:签名代码块用编辑器语法着色,分隔线、正文、示例和链接分开显示;纯文本包成代码块显示 - http/https/mailto 链接点击后用系统浏览器打开,打开后关闭弹窗 - 宽度在 280–620 之间按内容收窄,超过 420 高度时可滚动并显示细滚动条 - 弹窗贴在指针所在行的下沿,左缘对齐指针;下方放不下且上方更宽裕时翻到上方 - 指针停在同一符号范围内不再重复请求;移入弹窗时保持打开 - 离开符号和弹窗 400 ms 后才关闭,期间回到符号或弹窗会取消关闭,也会丢弃途中排队的 Hover 请求
xiaoyumuxi
marked this pull request as ready for review
November 14, 2026 02:59
21 of 26 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
Closes #。PR 类型 / Type
改动说明 / What changes
背景 / Why
编辑器里指针停在符号上弹出的 Hover 有三个问题:
```go、**等源码,签名、正文、示例和链接挤在一起,宽度固定。本 PR 让 Hover 按 IDEA/GoLand 的样子渲染,贴着指针所在行显示,并且允许指针移进弹窗。
改动 / Changes
渲染(新文件
desktop/internal/workbench/pluginsemantics_hover.go)components.MarkdownView渲染 Hover 内容:代码块、分隔线、标题、列表、行内代码、粗体、链接都按 Markdown 显示;正文用比例字体,代码用编辑器字体。isMarkdown: false)包成代码块显示,围栏长度大于正文里最长的反引号串;CRLF/CR 统一成 LF,Tab 展开为 4 个空格。operationFailed事件(复用已有事件,不新增事件)。desktop.semantics.hover,正文控件的标签是渲染后的完整文本。位置
semanticHoverWidth和pluginsemantics_view.go里的旧hoverPopup。保持与延迟关闭(
pluginsemantics.go、root.go)_、$)。指针在这个范围内移动时不再重新请求。root.go在窗口级指针回调前加hoverTrackPointer:指针在弹窗矩形内时保持打开;落在编辑器文档上时交给编辑器判断;落在其他位置时开始延迟关闭。pluginSemanticsReset重置新增的hoverHideDelay测试开关;closeSemanticHover会先停止待执行的关闭。测试与矩阵
pluginsemantics_hover_test.go,覆盖:shared/platform-feature-matrix/features/lsp-completion-hover.json:两端证据加入新文件,验证说明追加 2026-11-14 的行为;状态仍为 partial / pending。不在本 PR 范围内 / Out of scope
file:与工作区内跳转链接不处理(点击无反应)。internal/editor/**、internal/editorview/**。类型专属:fix
复现与根因
复现步骤、实际结果、期望结果:在装有语言服务器的 Go/Java 文件里,把指针停在函数名上约 500 ms。实际结果:
期望结果:渲染后的文档贴在所在行下方,指针可以移进弹窗阅读并点击链接。
根因(
git log -S semanticHoverWidth/semanticHoverDelay):0faecba49(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799,Viva 迁移)引入的 Hover 有以下问题:event.X + 12, event.Y + 18。pluginSemanticsPointer在指针离开编辑器文档(d == nil,包括移进弹窗)时立即closeSemanticHover。pointPluginHover重新计时、重新请求。影响平台:macOS 与 Windows(同一份 Viva 桌面端代码)。
检查项
hover.rect、hideCancel、hover.page、hoverWordSpan),无法在修复前的代码上编译;修复后desktop/internal/workbench/pluginsemantics_hover_test.go全部通过。startProviderHover、startPluginHover、showSemanticHover、hoverPopup的调用都在pluginsemantics.go/pluginsemantics_view.go,已全部更新;插件契约、SDK、脚本不涉及。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/lsp-completion-hover.json:两端加入新证据文件,验证说明如实写明只完成无头测试,状态保持 partial / pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(221 项通过)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh <preview> HEAD(通过).artifacts/下生成的矩阵视图统一日志系统 / Structured logging
operationFailedEvent与operationFailedFields("plugin_semantics", err),没有新增事件、没有print/stderr// log-exempt: 用户取消:…node scripts/logging/generate-log-events.mjs --check与verify-log-usage.mjs:本仓库 Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799 之后已没有scripts/logging/,无法运行界面文案 / i18n
desktop.semantics.hover,其余内容是语言服务器返回的文档(不翻译)node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,均通过,没有放宽脚本逻辑归属 / Logic placement
性能与内存 / Performance and memory
internal/editor/**、internal/editorview/**,不需要编辑器基线设置 / Settings
N/A:没有新增或修改设置。
插件契约 / Plugin contract
N/A:不改契约、能力版本或宿主方法,只消费已有的 Hover 结果(
contents、isMarkdown、range)。发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh(macOS 与 Windows 源码静态检查通过)无用代码与重构 / Dead code and refactoring
hoverPopup和semanticHoverWidth常量已删除验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/workbench/ -run 'Hover|Semantic' -count=1 -vscripts/desktop/desktop-go.sh test ./internal/workbench/ -count=1(变基到 preview 1cad09c 后)scripts/desktop/desktop-go.sh vet ./internal/workbench/gofmt -l desktop/internal/workbench/.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/workbench -- --filter 'TestPointerHover|TestHover'node scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh./scripts/desktop/verify/verify-runtime-bundle-immutability.sh未能执行的检查和原因:
提交前确认 / Final checks
preview(1cad09c2a),目标分支preview