Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/file-view.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{CompositeDisposable} = require 'atom'
{$$} = require 'atom-space-pen-views'
SymbolsView = require './symbols-view'

Expand All @@ -6,16 +7,16 @@ class FileView extends SymbolsView
initialize: ->
super

@editorsSubscription = atom.workspace.observeTextEditors (editor) =>
disposable = editor.onDidSave =>
@disposables = new CompositeDisposable()

@disposables.add atom.workspace.observeTextEditors (editor) =>
@disposables.add editor.onDidSave =>
f = editor.getPath()
return unless atom.project.contains(f)
@ctagsCache.generateTags(f, true)

editor.onDidDestroy -> disposable.dispose()

destroy: ->
@editorsSubscription.dispose()
@disposables.dispose()
super

viewForItem: ({lineNumber, name, file, pattern}) ->
Expand Down
20 changes: 9 additions & 11 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $ = null

MouseEventWhichDict = {"left click": 1, "middle click": 2, "right click": 3}
module.exports =
disposable: null
disposables: new CompositeDisposable()

config:
disableComplete:
Expand Down Expand Up @@ -50,26 +50,26 @@ module.exports =
@ctagsCache.activate()

@ctagsCache.initTags(atom.project.getPaths(), atom.config.get('atom-ctags.autoBuildTagsWhenActive'))
@disposable = atom.project.onDidChangePaths (paths)=>
@disposables.add atom.project.onDidChangePaths (paths)=>
@ctagsCache.initTags(paths, atom.config.get('atom-ctags.autoBuildTagsWhenActive'))

atom.commands.add 'atom-workspace', 'atom-ctags:rebuild', (e, cmdArgs)=>
@disposables.add atom.commands.add 'atom-workspace', 'atom-ctags:rebuild', (e, cmdArgs)=>
console.error "rebuild: ", e
@ctagsCache.cmdArgs = cmdArgs if Array.isArray(cmdArgs)
@createFileView().rebuild(true)
if t
clearTimeout(t)
t = null

atom.commands.add 'atom-workspace', 'atom-ctags:toggle-project-symbols', =>
@disposables.add atom.commands.add 'atom-workspace', 'atom-ctags:toggle-project-symbols', =>
@createFileView().toggleAll()

atom.commands.add 'atom-text-editor',
@disposables.add atom.commands.add 'atom-text-editor',
'atom-ctags:toggle-file-symbols': => @createFileView().toggle()
'atom-ctags:go-to-declaration': => @createFileView().goto()
'atom-ctags:return-from-declaration': => @createGoBackView().toggle()

atom.workspace.observeTextEditors (editor) =>
@disposables.add atom.workspace.observeTextEditors (editor) =>
editorView = atom.views.getView(editor)
{$} = require 'atom-space-pen-views' unless $
$(editorView).on 'mousedown', (event) =>
Expand All @@ -85,22 +85,19 @@ module.exports =
atom-ctags replaces and enhances the symbols-view package.
Therefore, symbols-view has been disabled."

atom.config.observe 'atom-ctags.disableComplete', =>
@disposables.add atom.config.observe 'atom-ctags.disableComplete', =>
return unless @provider
@provider.disabled = atom.config.get('atom-ctags.disableComplete')

initExtraTagsTime = null
atom.config.observe 'atom-ctags.extraTagFiles', =>
@disposables.add atom.config.observe 'atom-ctags.extraTagFiles', =>
clearTimeout initExtraTagsTime if initExtraTagsTime
initExtraTagsTime = setTimeout((=>
@ctagsCache.initExtraTags(atom.config.get('atom-ctags.extraTagFiles').split(" "))
initExtraTagsTime = null
), 1000)

deactivate: ->
if @disposable?
@disposable.dispose()
@disposable = null

if @fileView?
@fileView.destroy()
Expand All @@ -119,6 +116,7 @@ module.exports =
@goBackView = null

@ctagsCache.deactivate()
@disposables.dispose()

createFileView: ->
unless @fileView?
Expand Down