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

Add auto-complete for local variables #3004

Merged
merged 5 commits into from
May 18, 2022

Conversation

pippolo84
Copy link
Contributor

Add auto-complete for local variables when using print or whatis commands.

case "print", "whatis":
localVars, err := t.client.ListLocalVariables(
api.EvalScope{GoroutineID: -1, Frame: t.cmds.frame, DeferredCall: 0},
t.loadConfig(),
Copy link
Member

Choose a reason for hiding this comment

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

use api.LoadConfig{} so we don't load as much, also the trie should be cached at least until a command is executed (i.e. cleared before the promptForInput call).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the advice! I reworked the code so to cache the local variables trie.

@@ -279,6 +289,19 @@ func (t *Term) Run() (int, error) {
_, _ = t.client.GetState()

for {
localVars, err := t.client.ListLocalVariables(
Copy link
Member

Choose a reason for hiding this comment

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

What I was thinking was only clearing the cache here (locs = nil) but filling it in the completer function (if locs == nil { call ListLocalVariables, etc... })

Copy link
Contributor Author

@pippolo84 pippolo84 May 17, 2022

Choose a reason for hiding this comment

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

Sorry, I misunderstood your comment above. You meant a lazy loading of the cache in the completer. Seems reasonable, I'm gonna fix it. Thanks.

Copy link
Member

@aarzilli aarzilli left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants