Support opening project outline view without open editor

This commit is contained in:
Kevin Sawicki 2012-12-17 11:09:34 -08:00 committed by Corey Johnson & Nathan Sobo
parent 57e45883bb
commit af99bac30a
3 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,6 @@
window.keymap.bindKeys '.editor' window.keymap.bindKeys '.editor'
'meta-j': 'outline-view:toggle-file-outline' 'meta-j': 'outline-view:toggle-file-outline'
'meta-J': 'outline-view:toggle-project-outline'
'meta-.': 'outline-view:jump-to-declaration' 'meta-.': 'outline-view:jump-to-declaration'
window.keymap.bindKeys 'body'
'meta-J': 'outline-view:toggle-project-outline'

View File

@ -68,7 +68,7 @@ class OutlineView extends SelectList
populateProjectOutline: -> populateProjectOutline: ->
@setLoading("Loading symbols...") @setLoading("Loading symbols...")
TagReader.getAllTags(@rootView.getActiveEditor()).done (tags) => TagReader.getAllTags(@rootView.project).done (tags) =>
if tags.length > 0 if tags.length > 0
@miniEditor.show() @miniEditor.show()
@maxItems = 10 @maxItems = 10
@ -85,7 +85,7 @@ class OutlineView extends SelectList
openTag: (tag) -> openTag: (tag) ->
position = tag.position position = tag.position
position = @getTagLine(tag) unless position position = @getTagLine(tag) unless position
@rootView.openInExistingEditor(tag.file, true, true) if tag.file @rootView.open(tag.file, {changeFocus: true, allowActiveEditorChange:true}) if tag.file
@moveToPosition(position) if position @moveToPosition(position) if position
moveToPosition: (position) -> moveToPosition: (position) ->

View File

@ -3,8 +3,7 @@ $ = require 'jquery'
module.exports = module.exports =
getTagsFile: (editor) -> getTagsFile: (project) ->
project = editor.rootView().project
tagsFile = project.resolve("tags") or project.resolve("TAGS") tagsFile = project.resolve("tags") or project.resolve("TAGS")
return tagsFile if fs.isFile(tagsFile) return tagsFile if fs.isFile(tagsFile)
@ -12,14 +11,14 @@ find: (editor) ->
word = editor.getTextInRange(editor.getCursor().getCurrentWordBufferRange()) word = editor.getTextInRange(editor.getCursor().getCurrentWordBufferRange())
return [] unless word.length > 0 return [] unless word.length > 0
tagsFile = @getTagsFile(editor) tagsFile = @getTagsFile(editor.rootView().project)
return [] unless tagsFile return [] unless tagsFile
$tags.find(tagsFile, word) or [] $tags.find(tagsFile, word) or []
getAllTags: (editor, callback) -> getAllTags: (project, callback) ->
deferred = $.Deferred() deferred = $.Deferred()
tagsFile = @getTagsFile(editor) tagsFile = @getTagsFile(project)
if tagsFile if tagsFile
$tags.getAllTagsAsync tagsFile, (tags) => $tags.getAllTagsAsync tagsFile, (tags) =>
deferred.resolve(tags) deferred.resolve(tags)