Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter on tag.name + tag.file, and relativize tag.file for more concise display #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
14 changes: 11 additions & 3 deletions lib/ctags-cache.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ module.exports =

stream = ctags.createReadStream(p)

stream.on 'error', (error)->
stream.on 'error', (error) =>
console.error 'atom-ctags: ', error

stream.on 'data', (tags)->
stream.on 'data', (tags) =>
for tag in tags
continue unless tag.pattern
data = container[tag.file]
if not data
data = []
container[tag.file] = data
@addFieldsToTag(tag)
data.push tag
stream.on 'end', ()->
stream.on 'end', () =>
console.log "[atom-ctags:readTags] #{p} cost: #{Date.now() - startTime}ms"
callback?()

Expand Down Expand Up @@ -97,3 +98,10 @@ module.exports =
@generateTags filePath, true, =>
tags = @cachedTags[filePath]
callback?(tags)

addFieldsToTag: (tag) ->
# Add .relFile, for .filterKey and for more concise display
[projectDir, relFile] = atom.workspace.project.relativizePath(tag.file)
tag.relFile = path.join(path.basename(projectDir), relFile)
# Add .filterKey, for FileView.getFilterKey
tag.filterKey = "#{tag.name} #{tag.relFile}"
6 changes: 4 additions & 2 deletions lib/file-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class FileView extends SymbolsView
@editorsSubscription.dispose()
super

viewForItem: ({lineNumber, name, file, pattern}) ->
getFilterKey: -> 'filterKey'

viewForItem: ({lineNumber, name, relFile, pattern}) ->
$$ ->
@li class: 'two-lines', =>
@div class: 'primary-line', =>
Expand All @@ -27,7 +29,7 @@ class FileView extends SymbolsView

@div class: 'secondary-line', =>
@span "Line: #{lineNumber}", class: 'pull-left'
@span file, class: 'pull-right'
@span relFile, class: 'pull-right'

toggle: ->
if @panel.isVisible()
Expand Down