Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: exclude tooltip completion type in hover (#316)

Myles Scolnickcb0e56f66217
diff --git a/frontend/src/core/codemirror/completion/Autocompleter.ts b/frontend/src/core/codemirror/completion/Autocompleter.ts
index 8ebde60358..c4828fb333 100644
--- a/frontend/src/core/codemirror/completion/Autocompleter.ts
+++ b/frontend/src/core/codemirror/completion/Autocompleter.ts
@@ -61,11 +61,13 @@ export const Autocompleter = {
position,
message,
limitToType,
+ excludeTypes,
exactName,
}: {
position: number;
message: CompletionResultMessage;
limitToType?: "tooltip";
+ excludeTypes?: string[];
exactName?: string;
}): Tooltip | undefined {
const options = [...message.options];
@@ -96,6 +98,10 @@ export const Autocompleter = {
return;
}
+ if (excludeTypes && excludeTypes.includes(firstOption.type)) {
+ return;
+ }
+
return {
pos: from,
end: from + firstOption.name.length,
diff --git a/frontend/src/core/codemirror/completion/completer.ts b/frontend/src/core/codemirror/completion/completer.ts
index 2938b9fbcc..7d3cd99af2 100644
--- a/frontend/src/core/codemirror/completion/completer.ts
+++ b/frontend/src/core/codemirror/completion/completer.ts
@@ -5,7 +5,7 @@ import { AUTOCOMPLETER, Autocompleter } from "./Autocompleter";
import { Logger } from "../../../utils/Logger";
import { CellId, HTMLCellId } from "@/core/model/ids";
import { getCellEditorView } from "@/core/state/cells";
-import { clearTooltips, dispatchShowTooltip } from "./hints";
+import { dispatchShowTooltip } from "./hints";
export async function completer(
context: CompletionContext
@@ -38,15 +38,11 @@ export async function completer(
});
// Find EditorView for the cell
const editorView = getCellEditorView(cellId);
+ if (editorView) {
+ dispatchShowTooltip(editorView, tooltip);
+ }
if (tooltip) {
- if (editorView) {
- dispatchShowTooltip(editorView, tooltip);
- }
return null;
- } else {
- if (editorView) {
- clearTooltips(editorView);
- }
}
return Autocompleter.asCompletionResult(context.pos, result);
diff --git a/frontend/src/core/codemirror/completion/hints.ts b/frontend/src/core/codemirror/completion/hints.ts
index 70f125919e..194b001d4f 100644
--- a/frontend/src/core/codemirror/completion/hints.ts
+++ b/frontend/src/core/codemirror/completion/hints.ts
@@ -39,6 +39,7 @@ export function hintTooltip() {
position: endToken,
message: result,
exactName: fullWord,
+ excludeTypes: ["tooltip"],
});
return tooltip ?? null;
},
@@ -69,9 +70,12 @@ export function hintTooltip() {
/**
* Dispatch an effect that shows a tooltip
*/
-export function dispatchShowTooltip(view: EditorView, tooltip: Tooltip): void {
+export function dispatchShowTooltip(
+ view: EditorView,
+ tooltip: Tooltip | undefined
+): void {
view.dispatch({
- effects: TooltipFromCompletionApi.of([tooltip]),
+ effects: TooltipFromCompletionApi.of([tooltip].filter(Boolean)),
});
}