mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-16 11:39:38 +08:00
🐛 fix(sql-editor): 修复表名悬停元数据重复展示
- 去除 Cmd/Ctrl 导航高亮 decoration 上的 hoverMessage - 统一由 SQL hover provider 输出对象元数据 - 补充回归断言,确保表元数据只展示一次
This commit is contained in:
@@ -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]?.();
|
||||
|
||||
@@ -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<string, unknown>) => {
|
||||
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),
|
||||
},
|
||||
},
|
||||
})),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user