Repository navigation
fix(desktop): 指针离开文本后同一字符可以再次悬浮出 Hover - #2004
Draft
xiaoyumuxi wants to merge 1 commit into
Draft
xiaoyumuxi wants to merge 1 commit into
xiaoyumuxi wants to merge 1 commit into
Conversation
指针停在一个字符上请求过 Hover 之后,悬浮候选(hoverCandidate)只在 holdSemanticHover 和关闭语义会话时清掉。按 Esc、指针移出窗口、移到标签栏 等其他控件、滚动编辑器、移到没有文档的区域,都会留下旧候选;指针回到同一个 字符时 pointPluginHover 认为已经问过,不再请求,Hover 不再出现。 - 新增 leaveSemanticHover:关闭弹层、取消正在等的 Hover 请求并清掉候选; Esc、编辑器 PointerExit、指针下没有文档、视图尚未绘制(PositionAt 返回 !ok)和滚动都走这条路径。 - 新增 dropHoverCandidate:停止请求前的等待并忘掉候选字符; holdSemanticHover 和 closePluginSemantics 复用它。 - hoverTrackPointer 在指针移到编辑器以外的控件时清掉候选。Viva 只把指针事件 发给指针下的控件,编辑器收不到 PointerExit,这里是唯一能看到这次移动的 地方;同时避免还在等待的 Hover 在旧位置弹出。 - 不在 closeSemanticHover 里清候选:延迟隐藏和空结果也会调用它,那样会取消 刚在新位置排上的 Hover,或让没有 Hover 的字符内移动重复请求。 测试: - TestPointerHoverAsksAgainOnTheSameCharacterAfterLeavingTheText 覆盖 Esc、 移出窗口、移到标签栏、滚动四种离开方式,修复前全部失败。 - TestPointerHoverLeavingTheTextDropsTheWait 确认等待中的 Hover 不会在指针 离开后发出请求。 - TestPointerHoverDoesNotAskAgainWithinACharacterWithoutHover 确认空结果后 在同一字符内移动不会重复请求。 Refs #1995
This branch has not been deployed
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
PR 类型 / Type
改动说明 / What changes
背景 / Why
指针在一个字符上停留、出现过 Hover 之后,只要指针离开了编辑区的文字(按 Esc、移出窗口、移到标签栏等其他控件、滚动编辑器),再回到同一个字符就不会再出现 Hover,也不会向语言服务器发
textDocument/hover,必须先经过别的字符才能恢复。原因是悬浮候选hoverCandidate在这些路径上没有清掉,pointPluginHover把回来的那次当成“已经问过”直接返回。改动 / Changes
desktop/internal/workbench/pluginsemantics_hover.goleaveSemanticHover:关闭弹层、取消正在等的 Hover 请求,并清掉候选字符。dropHoverCandidate:停止请求前的 500 ms 等待并忘掉候选字符;holdSemanticHover改为调用它(行为不变)。hoverTrackPointer:指针移到编辑器以外的元素(比如标签栏)时清掉候选;如果有指针打开的 Hover,仍按原来的延迟开始关闭。Viva 只把指针事件交给指针下的元素,编辑器在这种情况下收不到PointerExit,窗口级的hoverTrackPointer是唯一能看到这次移动的地方。顺带修掉一个相关问题:还在 500 ms 等待中的 Hover 不会再在指针离开后于旧位置弹出。desktop/internal/workbench/pluginsemantics.gopluginSemanticsKey)、PointerExit、指针下没有文档(d == nil)、视图尚未绘制(PositionAt返回!ok)四条路径改为调用leaveSemanticHover。pluginSemanticsScrolled先调用leaveSemanticHover:内容在指针下移动后,等待中的 Hover 会在已经滚走的位置打开。closePluginSemantics复用dropHoverCandidate,替换原来的内联取消和清空。hoverCandidate的注释写明候选在请求后保留(同一字符内移动不重复请求),离开文本时清掉。desktop/internal/workbench/editor_view.goPointerExit改为调用leaveSemanticHover。desktop/internal/workbench/pluginsemantics_hover_test.goTestPointerHoverAsksAgainOnTheSameCharacterAfterLeavingTheText:表驱动,覆盖 Esc、移出窗口、移到标签栏、滚动四种离开方式,回到同一字符后必须发出第 2 次请求并打开 Hover。TestPointerHoverLeavingTheTextDropsTheWait:等待中的 Hover 在指针移到标签栏后被取消,不发请求。TestPointerHoverDoesNotAskAgainWithinACharacterWithoutHover:服务器返回空 Hover 后,在同一字符内移动不重复请求(防止修复过度)。documentBounds,用于找到编辑区上方的标签栏位置。shared/platform-feature-matrix/features/lsp-completion-hover.jsonverification里补充 2026-11-16 的行为说明;两端状态保持partial/pending。没有采用 Issue 里“在
closeSemanticHover里重置候选”的建议:延迟隐藏(releaseSemanticHover)和空结果路径也会调用closeSemanticHover,在那里清候选会取消刚在新位置排上的 Hover,或让没有 Hover 的字符内移动反复请求(第三个测试覆盖这一点)。不在本 PR 范围内 / Out of scope
PINNED_CORE_REVISION。类型专属:fix
复现与根因
textDocument/hover请求。期望:和第一次一样请求并显示 Hover。git log -S或git blame查):git log -S "candidate.active"指向 0faecba(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799,Viva 迁移)。pointPluginHover遇到“和候选同一个位置且candidate.active”时直接返回,而候选只在holdSemanticHover和closePluginSemantics里清空。desktop/internal/workbench代码)。检查项
desktop/internal/workbench/pluginsemantics_hover_test.go。修复前TestPointerHoverAsksAgainOnTheSameCharacterAfterLeavingTheText的 escape、out_of_the_window、over_the_tab_bar、scroll 四个子测试都失败(第 2 次请求没有发出,requestCount一直是 1);TestPointerHoverLeavingTheTextDropsTheWait失败(指针离开后候选还在)。TestPointerHoverDoesNotAskAgainWithinACharacterWithoutHover修复前后都通过,用来约束行为不被改过头。holdSemanticHover、closeSemanticHover、releaseSemanticHover、hoverTrackPointer、a.semantics.candidate的调用方都在desktop/internal/workbench,macOS 和 Windows 共用。.agents/notes/implemented/bug-fix/记录:约束(不在closeSemanticHover清候选、编辑器收不到跨控件的PointerExit)写在leaveSemanticHover和hoverTrackPointer的注释里,并由上面三个回归测试锁定。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/<id>.json:lsp-completion-hover的verification增加本次行为;两端仍为partial/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第三节“插件归属与宿主零依赖”的自查命令,结果为空semanticFixture)shared/i18n/;插件的构建步骤、资源路径和补丁没有写进scripts/resources/、docs/ci-builds.md、Agent Note 或 Skill:没有涉及文案和资源。UI 验证 / UI evidence
统一日志系统 / Structured logging
N/A:没有新增或改动生命周期、终态、降级或失败路径的日志。
界面文案 / i18n
node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
性能与内存 / Performance and memory
设置 / Settings
N/A:没有新增或修改设置。
插件契约 / Plugin contract
N/A:没有改动插件契约、能力版本、插件函数协议或宿主方法。
发行包与资源 / Bundle and resources
N/A:没有新增或修改运行时资源、缓存、下载物或构建步骤。
无用代码与重构 / Dead code and refactoring
closePluginSemantics里的内联取消与清空已换成dropHoverCandidate)refactor标签的 Issue,没有在本 PR 顺手处理:未发现。验证 / Verification
./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestPointerHover'DoesNotAskAgainWithinACharacterWithoutHover通过./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'Hover|Semantic'./scripts/desktop/desktop-go.sh test ./..../scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'Hover|Semantic' -count=1./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/workbench --filter 'TestPointerHover'./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/platform-feature-matrix/verify-platform-feature-matrix.shdevelop-lithe第三节插件零依赖自查rgnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --checkgofmt -l desktop/internal/workbench/未能执行的检查和原因:
pending。提交前确认 / Final checks
main创建;目标分支:main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图