mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
@@ -1,6 +1,7 @@
|
||||
RootView = require 'root-view'
|
||||
OutlineView = require 'outline-view'
|
||||
TagGenerator = require 'outline-view/src/tag-generator'
|
||||
fs = require 'fs'
|
||||
|
||||
describe "OutlineView", ->
|
||||
[rootView, outlineView, setArraySpy] = []
|
||||
@@ -152,6 +153,21 @@ describe "OutlineView", ->
|
||||
expect(rootView.getActiveEditor().getPath()).toBe rootView.project.resolve("tagged-duplicate.js")
|
||||
expect(rootView.getActiveEditor().getCursorBufferPosition()).toEqual [0,4]
|
||||
|
||||
describe "when the tag is in a file that doesn't exist", ->
|
||||
beforeEach ->
|
||||
fs.move(rootView.project.resolve("tagged-duplicate.js"), rootView.project.resolve("tagged-duplicate-renamed.js"))
|
||||
|
||||
afterEach ->
|
||||
fs.move(rootView.project.resolve("tagged-duplicate-renamed.js"), rootView.project.resolve("tagged-duplicate.js"))
|
||||
|
||||
it "doesn't display the tag", ->
|
||||
rootView.open("tagged.js")
|
||||
editor = rootView.getActiveEditor()
|
||||
editor.setCursorBufferPosition([8,14])
|
||||
editor.trigger 'outline-view:jump-to-declaration'
|
||||
expect(outlineView.list.children('li').length).toBe 1
|
||||
expect(outlineView.list.children('li:first').find('.function-name')).toHaveText 'tagged.js'
|
||||
|
||||
describe "project outline", ->
|
||||
it "displays all tags", ->
|
||||
rootView.open("tagged.js")
|
||||
|
||||
@@ -102,7 +102,9 @@ class OutlineView extends SelectList
|
||||
getTagLine: (tag) ->
|
||||
pattern = $.trim(tag.pattern?.replace(/(^^\/\^)|(\$\/$)/g, '')) # Remove leading /^ and trailing $/
|
||||
return unless pattern
|
||||
for line, index in fs.read(@rootView.project.resolve(tag.file)).split('\n')
|
||||
file = @rootView.project.resolve(tag.file)
|
||||
return unless fs.isFile(file)
|
||||
for line, index in fs.read(file).split('\n')
|
||||
return new Point(index, 0) if pattern is $.trim(line)
|
||||
|
||||
jumpToDeclaration: ->
|
||||
|
||||
Reference in New Issue
Block a user