Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Singleton AutocompleteManager, Separate View's Model From AutocompleteManager - #186

Merged
joefitzgerald merged 65 commits into
masterfrom
singleton-autocomplete-manager
Jan 28, 2015
Merged

joefitzgerald merged 65 commits into
masterfrom
singleton-autocomplete-manager

Conversation

@joefitzgerald

Copy link
Copy Markdown
Contributor

This PR seeks to change autocomplete-plus such that AutocompleteManager is a singleton.

  • Rename select-list-element to suggestion-list-element
  • Add suggestion-list
  • Modify main.coffee to manage a single AutocompleteManager instance
  • Track providers in an associative array, associating providers with scopes
  • Modify provider registration functions to discard editor binding during provider registration
  • Determine scope(s) for editor provided during provider registration
  • Manage suggestion-list-element across editors
  • Ensure decoration and view migrate across editors without problems
  • Make modest FuzzyProvider enhancements
  • Add service-hub based API
  • Track provider registrations with scoped-property-store
  • Deprecate Provider and Suggestion

- Switch to singleton AutocompleteManager, decouple model/view from specific editor/editorView
- Tests fail everywhere, but the package is functional with go-plus
@joefitzgerald joefitzgerald self-assigned this Jan 5, 2015
@joefitzgerald joefitzgerald added this to the 2.0 milestone Jan 5, 2015
@joefitzgerald joefitzgerald changed the title Rename select-list-element >> suggestion-list-element Singleton AutocompleteManager, Separate View's Model From AutocompleteManager Jan 5, 2015
- Integrate service-hub for new Provider API
- Support prior API as v1.0.0
- New API registers providers for scopes (fixes #171)
@joefitzgerald

Copy link
Copy Markdown
Contributor Author

@nathansobo This PR integrates service-hub into autocomplete-plus. Would appreciate a review of the portion that integrates it, if you're open (in autocomplete-manager.coffee).

- Temporary Fix, Pending Deprecation Of Provider And Migration Of Providers Away From Provider Class
- Add Config For Scope Blacklist
- Add Title And Description To Config
@nathansobo

Copy link
Copy Markdown
Contributor

@joefitzgerald Awesome. I'll take a look today.

Comment thread lib/autocomplete-manager.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

currentPaneItem could be something other than an editor. In which case we should deregister the current editor and cancel any current autocomplete.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's still a TODO. How should we restrict what a 'valid' editor is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@park9140 I stubbed this out in 77baf6f, feel free to implement the method(s).

Comment thread lib/autocomplete-manager.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor suggestion: Could you bundle up the various disposables associated with an editor/buffer into a single CompositeDisposable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We do maintain a CompositeDisposable but we cannot use that for buffer / editor events, because we have a single AutocompleteManager which is subscribing / unsubscribing as pane items change.

Consequently we need to explicitly track those subscriptions - hence the code is the way it is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could create a composite disposable when doing editor subscriptions and only store an clear that one when we detatch from a given editor. If we have to bind to more events in the future this would make the pattern more explicit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like it. 👍 Sorry, a little slow on the uptake on that one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in fb0c8c3.

Comment thread lib/autocomplete-manager.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should break this out into a ProviderManager component. Since the job of the AutocompleteManager is to handle the editor and editor interactions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AutocompleteManager is to handle the editor and editor interactions.

Is it? I mean, I suppose it could be its sole purpose, but I think the Provider API makes sense there too, at least for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd lobby for it just to help keep this file from being so enormous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okie dokie. Extracting.

- Assists in tests, allows interested parties to act on event
- Guard against @providers being null during dispose
- Ensure disposed providers are unregistered after they are disposed
- Fixes #88
- In Addition To The Global Blacklist, This Fixes The Following Issues:
- Fixes #88
- Fixes #171
- Fixes #132
- Fixes #78
- Fixes #107
- Preference Is Given To Earlier Suggestions
- Fixes #84
@joefitzgerald

Copy link
Copy Markdown
Contributor Author

@nathansobo This is ready to 🚢. Would appreciate your review of the code as it currently stands. This includes use of scoped-property-store for storage of provider registrations and the global / provider blacklists. We have also inverted the service-hub directionality, autocomplete+ is now the consumer of providers.

joefitzgerald added a commit that referenced this pull request Jan 28, 2015
…nager

Singleton AutocompleteManager, Separate View's Model From AutocompleteManager
@joefitzgerald
joefitzgerald merged commit f2bebcf into master Jan 28, 2015
@joefitzgerald
joefitzgerald deleted the singleton-autocomplete-manager branch January 28, 2015 05:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.