Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] improvement: autocomplete functions #2883

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/core/codemirror/completion/Autocompleter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Autocompleter = {
info: () => constructCompletionInfoNode(option.completion_info),
};
}),
validFor: /^\w*$/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned about the performance hit from this.

Instead of deleting, can we fix this regex? From looking at the video in your issue, I wonder if /^\w+$/ would be better.

Copy link
Contributor Author

@Light2Dark Light2Dark Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @akshayka , you are right about the performance hit.
I've been a little stuck because any regex doesn't work well with other libraries, eg polars df

df = pl.DataFrame({
    "a": [1,2]
})
df.clo# <---- cursor here doesn't autocomplete

I don't know why I'm so stuck unfortunately 🥲, anyways i modified this regex for a minor improvement.

validFor: /^\w+$/,
};
},

Expand Down
5 changes: 1 addition & 4 deletions frontend/src/core/codemirror/completion/completer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function completer(
return null;
}

// If it is a tooltip, show it as a Tooltip instead of a completion
// If it is a tooltip, set it in the documentation panel
const tooltip = Autocompleter.asHoverTooltip({
position: context.pos,
message: result,
Expand All @@ -47,9 +47,6 @@ export async function completer(
documentation: tooltip.html ?? null,
});
}
if (tooltip) {
return null;
}
Comment on lines -50 to -52
Copy link
Contributor Author

@Light2Dark Light2Dark Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another thing @akshayka , this removal introduces some side effects. It's not ideal.

df = pl.DataFrame({
  "a": [1,2],# <--- cursor here will pop up an autocomplete for Dataframe which overrides Enter key
})

I am keen to revert this, an ideal solution is to display as just a tooltip, it would take me too long to implement imo :/. (unless you have some pointers, getting pretty lost haha)


return Autocompleter.asCompletionResult(context.pos, result);
}
2 changes: 1 addition & 1 deletion marimo/_runtime/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def complete(
glbls: dict[str, Any],
glbls_lock: threading.RLock,
stream: Stream,
docstrings_limit: int = 80,
docstrings_limit: int = 100,
timeout: float | None = None,
prefer_interpreter_completion: bool = False,
) -> None:
Expand Down
Loading