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

Completion including method local vars which are out of scope #5

Closed
rohrlich opened this issue Feb 3, 2019 · 4 comments
Closed

Completion including method local vars which are out of scope #5

rohrlich opened this issue Feb 3, 2019 · 4 comments

Comments

@rohrlich
Copy link
Contributor

rohrlich commented Feb 3, 2019

Local vars are being included in completion results, for example see screenshot,

screen shot 2019-02-03 at 10 15 09 am

@rohrlich
Copy link
Contributor Author

rohrlich commented Feb 5, 2019

I found the source of pi issue #5 but I’m undecided about the best way to fix. The problem is the recursion in the code below. I am leery about adding a bool recurse argument as the method as it would be necessary in a chain of methods. I lean towards a another set of methods that don’t recurse. It would mean some method name changes to make it clear which set did the recursion.

// FindNamePrefix looks for given symbol name prefix within this map
// and any children on the map.
// adds to given matches map (which can be nil), for more efficient recursive use
func (sm *SymMap) FindNamePrefix(seed string, matches *SymMap) {
noCase := true
if complete.HasUpperCase(seed) {
noCase = false
}
for _, sy := range *sm {
nm := sy.Name
if noCase {
nm = strings.ToLower(nm)
}
if strings.HasPrefix(nm, seed) {
if *matches == nil {
*matches = make(SymMap)
}
(*matches)[sy.Name] = sy
}
}
for _, ss := range *sm {
ss.Children.FindNamePrefix(seed, matches)
}
}

@rcoreilly
Copy link
Member

Yep go ahead and add a new set of methods. FindNamePrefixRecursive vs. FindNamePrefix?

@rohrlich
Copy link
Contributor Author

rohrlich commented Feb 5, 2019

Yes, that naming is very clear!

rohrlich added a commit that referenced this issue Feb 6, 2019
…ed FindNamePrefixRecursive

- Add FindChildren, same as FindAnyChildren but calls FindNamePrefix instead of recursive version
- Fixes pi issue #5
@rohrlich
Copy link
Contributor Author

rohrlich commented Feb 6, 2019

Done

@rohrlich rohrlich closed this as completed Feb 6, 2019
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

No branches or pull requests

2 participants