33
44MouseEventWhichDict = {" left click" : 1 , " middle click" : 2 , " right click" : 3 }
55module .exports =
6- disposable : null
6+ disposables : new CompositeDisposable ()
77
88 config :
99 disableComplete :
@@ -50,26 +50,26 @@ module.exports =
5050 @ctagsCache .activate ()
5151
5252 @ctagsCache .initTags (atom .project .getPaths (), atom .config .get (' atom-ctags.autoBuildTagsWhenActive' ))
53- @disposable = atom .project .onDidChangePaths (paths)=>
53+ @disposables . add atom .project .onDidChangePaths (paths)=>
5454 @ctagsCache .initTags (paths, atom .config .get (' atom-ctags.autoBuildTagsWhenActive' ))
5555
56- atom .commands .add ' atom-workspace' , ' atom-ctags:rebuild' , (e , cmdArgs )=>
56+ @disposables . add atom .commands .add ' atom-workspace' , ' atom-ctags:rebuild' , (e , cmdArgs )=>
5757 console .error " rebuild: " , e
5858 @ctagsCache .cmdArgs = cmdArgs if Array .isArray (cmdArgs)
5959 @ createFileView ().rebuild (true )
6060 if t
6161 clearTimeout (t)
6262 t = null
6363
64- atom .commands .add ' atom-workspace' , ' atom-ctags:toggle-project-symbols' , =>
64+ @disposables . add atom .commands .add ' atom-workspace' , ' atom-ctags:toggle-project-symbols' , =>
6565 @ createFileView ().toggleAll ()
6666
67- atom .commands .add ' atom-text-editor' ,
67+ @disposables . add atom .commands .add ' atom-text-editor' ,
6868 ' atom-ctags:toggle-file-symbols ' : => @ createFileView ().toggle ()
6969 ' atom-ctags:go-to-declaration ' : => @ createFileView ().goto ()
7070 ' atom-ctags:return-from-declaration ' : => @ createGoBackView ().toggle ()
7171
72- atom .workspace .observeTextEditors (editor) =>
72+ @disposables . add atom .workspace .observeTextEditors (editor) =>
7373 editorView = atom .views .getView (editor)
7474 {$ } = require ' atom-space-pen-views' unless $
7575 $ (editorView).on ' mousedown' , (event ) =>
@@ -85,22 +85,19 @@ module.exports =
8585 atom-ctags replaces and enhances the symbols-view package.
8686 Therefore, symbols-view has been disabled."
8787
88- atom .config .observe ' atom-ctags.disableComplete' , =>
88+ @disposables . add atom .config .observe ' atom-ctags.disableComplete' , =>
8989 return unless @provider
9090 @provider .disabled = atom .config .get (' atom-ctags.disableComplete' )
9191
9292 initExtraTagsTime = null
93- atom .config .observe ' atom-ctags.extraTagFiles' , =>
93+ @disposables . add atom .config .observe ' atom-ctags.extraTagFiles' , =>
9494 clearTimeout initExtraTagsTime if initExtraTagsTime
9595 initExtraTagsTime = setTimeout ((=>
9696 @ctagsCache .initExtraTags (atom .config .get (' atom-ctags.extraTagFiles' ).split (" " ))
9797 initExtraTagsTime = null
9898 ), 1000 )
9999
100100 deactivate : ->
101- if @disposable ?
102- @disposable .dispose ()
103- @disposable = null
104101
105102 if @fileView ?
106103 @fileView .destroy ()
@@ -119,6 +116,7 @@ module.exports =
119116 @goBackView = null
120117
121118 @ctagsCache .deactivate ()
119+ @disposables .dispose ()
122120
123121 createFileView : ->
124122 unless @fileView ?
0 commit comments