-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
pkg/terminal/terminal.go
Outdated
case "print", "whatis": | ||
localVars, err := t.client.ListLocalVariables( | ||
api.EvalScope{GoroutineID: -1, Frame: t.cmds.frame, DeferredCall: 0}, | ||
t.loadConfig(), |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
pkg/terminal/terminal.go
Outdated
@@ -279,6 +289,19 @@ func (t *Term) Run() (int, error) { | |||
_, _ = t.client.GetState() | |||
|
|||
for { | |||
localVars, err := t.client.ListLocalVariables( |
There was a problem hiding this comment.
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... }
)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add auto-complete for local variables when using
print
orwhatis
commands.