Commit d3e112ed authored by yann300's avatar yann300

allow one highlighter per plugin

parent fdb869e1
...@@ -5,7 +5,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter') ...@@ -5,7 +5,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter')
Defines available API. `key` / `type` Defines available API. `key` / `type`
*/ */
module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => { module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => {
var highlighter = new SourceHighlighter() let highlighters = {}
return { return {
app: { app: {
getExecutionContextProvider: (mod, cb) => { getExecutionContextProvider: (mod, cb) => {
...@@ -136,12 +136,13 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => ...@@ -136,12 +136,13 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
} catch (e) { } catch (e) {
return cb(e.message) return cb(e.message)
} }
highlighter.currentSourceLocation(null) if (!highlighters[mod]) highlighters[mod] = new SourceHighlighter()
highlighter.currentSourceLocationFromfileName(position, filePath, hexColor) highlighters[mod].currentSourceLocation(null)
highlighters[mod].currentSourceLocationFromfileName(position, filePath, hexColor)
cb() cb()
}, },
discardHighlight: (mod, cb) => { discardHighlight: (mod, cb) => {
highlighter.currentSourceLocation(null) if (highlighters[mod]) highlighters[mod].currentSourceLocation(null)
cb() cb()
} }
} }
......
...@@ -90,6 +90,7 @@ module.exports = class PluginManager { ...@@ -90,6 +90,7 @@ module.exports = class PluginManager {
compiler, compiler,
udapp udapp
) )
self._components = { pluginAPI }
self.plugins = {} self.plugins = {}
self.origins = {} self.origins = {}
self.inFocus self.inFocus
...@@ -181,6 +182,7 @@ module.exports = class PluginManager { ...@@ -181,6 +182,7 @@ module.exports = class PluginManager {
} }
unregister (desc) { unregister (desc) {
const self = this const self = this
self._components.pluginAPI.editor.discardHighlight(desc.title, () => {})
delete self.plugins[desc.title] delete self.plugins[desc.title]
delete self.origins[desc.url] delete self.origins[desc.url]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment