From a9d515f160574182a8a92dcbf9baf6f12f9555df Mon Sep 17 00:00:00 2001 From: Syngnat Date: Thu, 4 Jun 2026 10:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(sql-editor):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=A1=A8=E5=90=8D=E6=82=AC=E5=81=9C=E5=85=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=87=8D=E5=A4=8D=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 去除 Cmd/Ctrl 导航高亮 decoration 上的 hoverMessage - 统一由 SQL hover provider 输出对象元数据 - 补充回归断言,确保表元数据只展示一次 --- .../QueryEditor.external-sql-save.test.tsx | 11 ++++++-- frontend/src/components/QueryEditor.tsx | 27 ------------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/QueryEditor.external-sql-save.test.tsx b/frontend/src/components/QueryEditor.external-sql-save.test.tsx index 878d84f..8ea484a 100644 --- a/frontend/src/components/QueryEditor.external-sql-save.test.tsx +++ b/frontend/src/components/QueryEditor.external-sql-save.test.tsx @@ -777,8 +777,15 @@ describe('QueryEditor external SQL save', () => { expect(editorState.domNode.style.cursor).toBe('pointer'); const lastDecorationCall = editorState.editor.deltaDecorations.mock.calls.at(-1); expect(lastDecorationCall?.[1]?.[0]?.options?.inlineClassName).toBe('gonavi-query-editor-link-hint'); - expect(lastDecorationCall?.[1]?.[0]?.options?.hoverMessage?.value).toMatch(/(?:Ctrl|⌘) \+ 点击打开该表/); - expect(lastDecorationCall?.[1]?.[0]?.options?.hoverMessage?.value).toContain('**表** `events`'); + expect(lastDecorationCall?.[1]?.[0]?.options?.hoverMessage).toBeUndefined(); + + const hover = editorState.hoverProviders[0]?.provideHover( + editorState.editor.getModel(), + { lineNumber: 1, column: 27 }, + ); + const hoverText = String(hover?.contents?.[0]?.value || ''); + expect(hoverText.match(/\*\*表\*\*/g)).toHaveLength(1); + expect(hoverText).toContain('**表** `events`'); await act(async () => { editorState.mouseLeaveListeners[0]?.(); diff --git a/frontend/src/components/QueryEditor.tsx b/frontend/src/components/QueryEditor.tsx index 6fa4920..58c79cc 100644 --- a/frontend/src/components/QueryEditor.tsx +++ b/frontend/src/components/QueryEditor.tsx @@ -1630,16 +1630,6 @@ export const resolveQueryEditorNavigationDecorations = ( }]; }; -const buildQueryEditorNavigationHoverMarkdown = ( - hoverTarget: QueryEditorHoverTarget | null, - actionHint: string, -): string => { - const hoverContent = hoverTarget ? buildQueryEditorHoverMarkdown(hoverTarget) : ''; - return hoverContent - ? `${hoverContent}\n\n---\n\n${actionHint}` - : actionHint; -}; - const dispatchQueryEditorSidebarLocate = (detail: Record) => { if (typeof window === 'undefined') { return; @@ -2652,20 +2642,6 @@ const QueryEditor: React.FC<{ tab: TabData; isActive?: boolean }> = ({ tab, isAc setQueryEditorMouseCursor(editor, ''); return; } - const hoverTarget = resolveQueryEditorHoverTarget( - getQueryEditorObjectResolveText(model, lineContent), - lineContent, - targetPosition.column, - currentDbRef.current, - visibleDbsRef.current, - tablesRef.current, - allColumnsRef.current, - viewsRef.current, - materializedViewsRef.current, - triggersRef.current, - routinesRef.current, - ); - linkDecorationIdsRef.current = editor.deltaDecorations( linkDecorationIdsRef.current, decorations.map((item) => ({ @@ -2677,9 +2653,6 @@ const QueryEditor: React.FC<{ tab: TabData; isActive?: boolean }> = ({ tab, isAc ), options: { inlineClassName: 'gonavi-query-editor-link-hint', - hoverMessage: { - value: buildQueryEditorNavigationHoverMarkdown(hoverTarget, item.hoverMessage), - }, }, })), );