atom / autocomplete-plus

View and insert possible completions in the editor while typing
MIT License
960 stars 263 forks source link

Typing such that scope becomes blacklisted should hide suggestions #650

Open gdaolewe opened 8 years ago

gdaolewe commented 8 years ago

Easiest way to reproduce for me:

Install https://atom.io/packages/autocomplete-paths Add .comment to scope blacklist in autocomplete-plus settings Open an empty .js file Type /, suggestions from autocomplete-paths show up as I expect Type / again or * to open a comment, cursor is now in a blacklisted scope, but suggestions are still shown. In my opinion, entering a blacklisted scope should hide the suggestions.

gdaolewe commented 8 years ago

I'd be interested in creating a PR for this, but I may need a little guidance as I haven't contributed to Atom/Atom packages or written any CoffeeScript previously. It seems like the basic approach would be to observe and store the scopeBlacklist config property, and then in autocomplete-manager::bufferChanged() call a function to check if the editor's current scope is blacklisted. However, I don't see any convenient way to compare the current scopeDescriptor to the simple array returned by atom.config.get('autocomplete-plus.scopeBlacklist').

The other way I thought of solving this was simply checking the length of @providerManager.providersForScopeDescriptor(scopeDescriptor), if it's 0 in bufferChanged() then don't activate.

lee-dohm commented 8 years ago

If you're going to try to fix it, have you checked to ensure that when typing a partial line, Atom already knows that it is in a comment? It's possible that the underlying issue is not with autocomplete-plus but with the individual language packages or the grammar system.

gdaolewe commented 8 years ago

@lee-dohm Yes, at that point the scope chain contains comment.

EDIT: and also, when bufferChanged() is called on typing the first /, autocomplete-paths is in the list of providersForScopeDescriptor, but when subsequently typing / or * it isn't, which is why I concluded this was an issue with autocomplete-plus.

lee-dohm commented 8 years ago

Ok cool ... I just didn't want you going down a rabbit hole unnecessarily :grinning: