-
Notifications
You must be signed in to change notification settings - Fork 8
Handle multiple workspaces in a project #46
Conversation
if (this.editorService) { | ||
this.editorService.dispose(); | ||
// TODO(timvdlippe): Expose as user setting? | ||
if (this.workspaces.size == 10) { |
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.
Should probably be >= 10
to guard against adding a workspace if not one was removed, but also one was added.
lintOnFly: true, | ||
lint: (editor) => { | ||
const project = this.getProjectPathFromEditor(editor); | ||
return this.workspaces.get(project)[1].linter.lint(editor); |
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 if project does not exist in this.workspaces
?
selector: '.text.html, .source.js', | ||
getSuggestions: (options) => { | ||
const project = this.getProjectPathFromEditor(options.editor); | ||
return this.workspaces.get(project)[1].autocompleter.getSuggestions(options); |
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 if project does not exist in this.workspaces
?
deactivate() { | ||
this.subscriptions.dispose(); | ||
this.subscriptions = null; | ||
this.workspaces = new Map(); |
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.
Do we also need to clean up the linter, autocompleter and tooltipmanager or is this already sufficient? We could also add them to this.subscriptions
when we create them inside updateWorkspaceMap
Yes, this should be handled at the atom-languageclient level if it isn't already. |
The plugin should now be able to handle multiple projects. It does so by keeping track of at most 10 workspaces at the same time. Every time a file is opened, the workspace is inserted or the file counter is incremented. When a file is closed, the workspace file counter is decremented.
If there are more than 10 workspaces, it will try to remove the first workspace that has no more files open and remove that workspace from the map.
When the linter or autocomplete functions are invoked, the corresponding linter/autcompleter of the editor is looked up and returned.
Fixes #6