Deprecate Project::resolve
It’s not something that will make sense once we add the ability to have multiple directories in a project. This adds a new private method on Project, ::resolvePath, with the original implementation for convenience until we actually implement multi-folder projects.
Esse commit está contido em:
+1
-1
@@ -45,7 +45,7 @@
|
|||||||
"nslog": "^1.0.1",
|
"nslog": "^1.0.1",
|
||||||
"oniguruma": "^3.0.4",
|
"oniguruma": "^3.0.4",
|
||||||
"optimist": "0.4.0",
|
"optimist": "0.4.0",
|
||||||
"pathwatcher": "^2.3.7",
|
"pathwatcher": "^2.5.0",
|
||||||
"property-accessors": "^1",
|
"property-accessors": "^1",
|
||||||
"q": "^1.0.1",
|
"q": "^1.0.1",
|
||||||
"random-words": "0.0.1",
|
"random-words": "0.0.1",
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ describe "Package", ->
|
|||||||
spyOn(atom, 'inDevMode').andReturn(false)
|
spyOn(atom, 'inDevMode').andReturn(false)
|
||||||
|
|
||||||
it "does not activate it", ->
|
it "does not activate it", ->
|
||||||
packagePath = atom.project.resolve('packages/package-with-incompatible-native-module')
|
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-incompatible-native-module')
|
||||||
pack = new Package(packagePath)
|
pack = new Package(packagePath)
|
||||||
expect(pack.isCompatible()).toBe false
|
expect(pack.isCompatible()).toBe false
|
||||||
expect(pack.incompatibleModules[0].name).toBe 'native-module'
|
expect(pack.incompatibleModules[0].name).toBe 'native-module'
|
||||||
expect(pack.incompatibleModules[0].path).toBe path.join(packagePath, 'node_modules', 'native-module')
|
expect(pack.incompatibleModules[0].path).toBe path.join(packagePath, 'node_modules', 'native-module')
|
||||||
|
|
||||||
it "caches the incompatible native modules in local storage", ->
|
it "caches the incompatible native modules in local storage", ->
|
||||||
packagePath = atom.project.resolve('packages/package-with-incompatible-native-module')
|
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-incompatible-native-module')
|
||||||
cacheKey = null
|
cacheKey = null
|
||||||
cacheItem = null
|
cacheItem = null
|
||||||
|
|
||||||
@@ -46,14 +46,14 @@ describe "Package", ->
|
|||||||
describe "when the theme contains a single style file", ->
|
describe "when the theme contains a single style file", ->
|
||||||
it "loads and applies css", ->
|
it "loads and applies css", ->
|
||||||
expect($("atom-text-editor").css("padding-bottom")).not.toBe "1234px"
|
expect($("atom-text-editor").css("padding-bottom")).not.toBe "1234px"
|
||||||
themePath = atom.project.resolve('packages/theme-with-index-css')
|
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-index-css')
|
||||||
theme = new ThemePackage(themePath)
|
theme = new ThemePackage(themePath)
|
||||||
theme.activate()
|
theme.activate()
|
||||||
expect($("atom-text-editor").css("padding-top")).toBe "1234px"
|
expect($("atom-text-editor").css("padding-top")).toBe "1234px"
|
||||||
|
|
||||||
it "parses, loads and applies less", ->
|
it "parses, loads and applies less", ->
|
||||||
expect($("atom-text-editor").css("padding-bottom")).not.toBe "1234px"
|
expect($("atom-text-editor").css("padding-bottom")).not.toBe "1234px"
|
||||||
themePath = atom.project.resolve('packages/theme-with-index-less')
|
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-index-less')
|
||||||
theme = new ThemePackage(themePath)
|
theme = new ThemePackage(themePath)
|
||||||
theme.activate()
|
theme.activate()
|
||||||
expect($("atom-text-editor").css("padding-top")).toBe "4321px"
|
expect($("atom-text-editor").css("padding-top")).toBe "4321px"
|
||||||
@@ -64,7 +64,7 @@ describe "Package", ->
|
|||||||
expect($("atom-text-editor").css("padding-right")).not.toBe("102px")
|
expect($("atom-text-editor").css("padding-right")).not.toBe("102px")
|
||||||
expect($("atom-text-editor").css("padding-bottom")).not.toBe("103px")
|
expect($("atom-text-editor").css("padding-bottom")).not.toBe("103px")
|
||||||
|
|
||||||
themePath = atom.project.resolve('packages/theme-with-package-file')
|
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-package-file')
|
||||||
theme = new ThemePackage(themePath)
|
theme = new ThemePackage(themePath)
|
||||||
theme.activate()
|
theme.activate()
|
||||||
expect($("atom-text-editor").css("padding-top")).toBe("101px")
|
expect($("atom-text-editor").css("padding-top")).toBe("101px")
|
||||||
@@ -77,7 +77,7 @@ describe "Package", ->
|
|||||||
expect($("atom-text-editor").css("padding-right")).not.toBe "20px"
|
expect($("atom-text-editor").css("padding-right")).not.toBe "20px"
|
||||||
expect($("atom-text-editor").css("padding-bottom")).not.toBe "30px"
|
expect($("atom-text-editor").css("padding-bottom")).not.toBe "30px"
|
||||||
|
|
||||||
themePath = atom.project.resolve('packages/theme-without-package-file')
|
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-without-package-file')
|
||||||
theme = new ThemePackage(themePath)
|
theme = new ThemePackage(themePath)
|
||||||
theme.activate()
|
theme.activate()
|
||||||
expect($("atom-text-editor").css("padding-top")).toBe "10px"
|
expect($("atom-text-editor").css("padding-top")).toBe "10px"
|
||||||
@@ -86,7 +86,7 @@ describe "Package", ->
|
|||||||
|
|
||||||
describe "reloading a theme", ->
|
describe "reloading a theme", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
themePath = atom.project.resolve('packages/theme-with-package-file')
|
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-package-file')
|
||||||
theme = new ThemePackage(themePath)
|
theme = new ThemePackage(themePath)
|
||||||
theme.activate()
|
theme.activate()
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ describe "Package", ->
|
|||||||
|
|
||||||
describe "events", ->
|
describe "events", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
themePath = atom.project.resolve('packages/theme-with-package-file')
|
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-package-file')
|
||||||
theme = new ThemePackage(themePath)
|
theme = new ThemePackage(themePath)
|
||||||
theme.activate()
|
theme.activate()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ BufferedProcess = require '../src/buffered-process'
|
|||||||
|
|
||||||
describe "Project", ->
|
describe "Project", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
atom.project.setPaths([atom.project.resolve('dir')])
|
atom.project.setPaths([atom.project.getDirectories()[0]?.resolve('dir')])
|
||||||
|
|
||||||
describe "serialization", ->
|
describe "serialization", ->
|
||||||
deserializedProject = null
|
deserializedProject = null
|
||||||
@@ -109,7 +109,7 @@ describe "Project", ->
|
|||||||
expect(newBufferHandler).toHaveBeenCalledWith(editor.buffer)
|
expect(newBufferHandler).toHaveBeenCalledWith(editor.buffer)
|
||||||
|
|
||||||
it "returns number of read bytes as progress indicator", ->
|
it "returns number of read bytes as progress indicator", ->
|
||||||
filePath = atom.project.resolve 'a'
|
filePath = atom.project.getDirectories()[0]?.resolve 'a'
|
||||||
totalBytes = 0
|
totalBytes = 0
|
||||||
promise = atom.project.open(filePath)
|
promise = atom.project.open(filePath)
|
||||||
promise.progress (bytesRead) -> totalBytes = bytesRead
|
promise.progress (bytesRead) -> totalBytes = bytesRead
|
||||||
@@ -148,27 +148,6 @@ describe "Project", ->
|
|||||||
atom.project.bufferForPath("b").then (anotherBuffer) ->
|
atom.project.bufferForPath("b").then (anotherBuffer) ->
|
||||||
expect(anotherBuffer).not.toBe buffer
|
expect(anotherBuffer).not.toBe buffer
|
||||||
|
|
||||||
describe ".resolve(uri)", ->
|
|
||||||
describe "when passed an absolute or relative path", ->
|
|
||||||
it "returns an absolute path based on the atom.project's root", ->
|
|
||||||
absolutePath = require.resolve('./fixtures/dir/a')
|
|
||||||
expect(atom.project.resolve('a')).toBe absolutePath
|
|
||||||
expect(atom.project.resolve(absolutePath + '/../a')).toBe absolutePath
|
|
||||||
expect(atom.project.resolve('a/../a')).toBe absolutePath
|
|
||||||
expect(atom.project.resolve()).toBeUndefined()
|
|
||||||
|
|
||||||
describe "when passed a uri with a scheme", ->
|
|
||||||
it "does not modify uris that begin with a scheme", ->
|
|
||||||
expect(atom.project.resolve('http://zombo.com')).toBe 'http://zombo.com'
|
|
||||||
|
|
||||||
describe "when the project has no path", ->
|
|
||||||
it "returns undefined for relative URIs", ->
|
|
||||||
atom.project.setPaths([])
|
|
||||||
expect(atom.project.resolve('test.txt')).toBeUndefined()
|
|
||||||
expect(atom.project.resolve('http://github.com')).toBe 'http://github.com'
|
|
||||||
absolutePath = fs.absolute(__dirname)
|
|
||||||
expect(atom.project.resolve(absolutePath)).toBe absolutePath
|
|
||||||
|
|
||||||
describe ".setPaths(path)", ->
|
describe ".setPaths(path)", ->
|
||||||
describe "when path is a file", ->
|
describe "when path is a file", ->
|
||||||
it "sets its path to the files parent directory and updates the root directory", ->
|
it "sets its path to the files parent directory and updates the root directory", ->
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ describe "ThemeManager", ->
|
|||||||
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
|
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
|
||||||
themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")
|
themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")
|
||||||
|
|
||||||
cssPath = atom.project.resolve('css.css')
|
cssPath = atom.project.getDirectories()[0]?.resolve('css.css')
|
||||||
lengthBefore = $('head style').length
|
lengthBefore = $('head style').length
|
||||||
|
|
||||||
themeManager.requireStylesheet(cssPath)
|
themeManager.requireStylesheet(cssPath)
|
||||||
@@ -194,7 +194,7 @@ describe "ThemeManager", ->
|
|||||||
$('head style[id*="css.css"]').remove()
|
$('head style[id*="css.css"]').remove()
|
||||||
|
|
||||||
it "synchronously loads and parses less files at the given path and installs a style tag for it in the head", ->
|
it "synchronously loads and parses less files at the given path and installs a style tag for it in the head", ->
|
||||||
lessPath = atom.project.resolve('sample.less')
|
lessPath = atom.project.getDirectories()[0]?.resolve('sample.less')
|
||||||
lengthBefore = $('head style').length
|
lengthBefore = $('head style').length
|
||||||
themeManager.requireStylesheet(lessPath)
|
themeManager.requireStylesheet(lessPath)
|
||||||
expect($('head style').length).toBe lengthBefore + 1
|
expect($('head style').length).toBe lengthBefore + 1
|
||||||
@@ -218,9 +218,9 @@ describe "ThemeManager", ->
|
|||||||
|
|
||||||
it "supports requiring css and less stylesheets without an explicit extension", ->
|
it "supports requiring css and less stylesheets without an explicit extension", ->
|
||||||
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'css')
|
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'css')
|
||||||
expect($('head style[source-path*="css.css"]').attr('source-path')).toBe themeManager.stringToId(atom.project.resolve('css.css'))
|
expect($('head style[source-path*="css.css"]').attr('source-path')).toBe themeManager.stringToId(atom.project.getDirectories()[0]?.resolve('css.css'))
|
||||||
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'sample')
|
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'sample')
|
||||||
expect($('head style[source-path*="sample.less"]').attr('source-path')).toBe themeManager.stringToId(atom.project.resolve('sample.less'))
|
expect($('head style[source-path*="sample.less"]').attr('source-path')).toBe themeManager.stringToId(atom.project.getDirectories()[0]?.resolve('sample.less'))
|
||||||
|
|
||||||
$('head style[id*="css.css"]').remove()
|
$('head style[id*="css.css"]').remove()
|
||||||
$('head style[id*="sample.less"]').remove()
|
$('head style[id*="sample.less"]').remove()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe "Workspace", ->
|
|||||||
workspace = null
|
workspace = null
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
atom.project.setPaths([atom.project.resolve('dir')])
|
atom.project.setPaths([atom.project.getDirectories()[0]?.resolve('dir')])
|
||||||
atom.workspace = workspace = new Workspace
|
atom.workspace = workspace = new Workspace
|
||||||
|
|
||||||
describe "::open(uri, options)", ->
|
describe "::open(uri, options)", ->
|
||||||
@@ -70,19 +70,19 @@ describe "Workspace", ->
|
|||||||
|
|
||||||
expect(openEvents).toEqual [
|
expect(openEvents).toEqual [
|
||||||
{
|
{
|
||||||
uri: atom.project.resolve('a')
|
uri: atom.project.getDirectories()[0]?.resolve('a')
|
||||||
item: editor1
|
item: editor1
|
||||||
pane: atom.workspace.getActivePane()
|
pane: atom.workspace.getActivePane()
|
||||||
index: 0
|
index: 0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
uri: atom.project.resolve('b')
|
uri: atom.project.getDirectories()[0]?.resolve('b')
|
||||||
item: editor2
|
item: editor2
|
||||||
pane: atom.workspace.getActivePane()
|
pane: atom.workspace.getActivePane()
|
||||||
index: 1
|
index: 1
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
uri: atom.project.resolve('a')
|
uri: atom.project.getDirectories()[0]?.resolve('a')
|
||||||
item: editor1
|
item: editor1
|
||||||
pane: atom.workspace.getActivePane()
|
pane: atom.workspace.getActivePane()
|
||||||
index: 0
|
index: 0
|
||||||
@@ -96,7 +96,7 @@ describe "Workspace", ->
|
|||||||
workspace.open('a').then (o) -> editor = o
|
workspace.open('a').then (o) -> editor = o
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(editor.getUri()).toBe atom.project.resolve('a')
|
expect(editor.getUri()).toBe atom.project.getDirectories()[0]?.resolve('a')
|
||||||
expect(workspace.getActivePaneItem()).toBe editor
|
expect(workspace.getActivePaneItem()).toBe editor
|
||||||
expect(workspace.getActivePane().items).toEqual [editor]
|
expect(workspace.getActivePane().items).toEqual [editor]
|
||||||
expect(workspace.getActivePane().activate).toHaveBeenCalled()
|
expect(workspace.getActivePane().activate).toHaveBeenCalled()
|
||||||
@@ -230,7 +230,7 @@ describe "Workspace", ->
|
|||||||
workspace.addOpener(barOpener)
|
workspace.addOpener(barOpener)
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
pathToOpen = atom.project.resolve('a.foo')
|
pathToOpen = atom.project.getDirectories()[0]?.resolve('a.foo')
|
||||||
workspace.open(pathToOpen, hey: "there").then (item) ->
|
workspace.open(pathToOpen, hey: "there").then (item) ->
|
||||||
expect(item).toEqual { foo: pathToOpen, options: {hey: "there"} }
|
expect(item).toEqual { foo: pathToOpen, options: {hey: "there"} }
|
||||||
|
|
||||||
@@ -271,11 +271,11 @@ describe "Workspace", ->
|
|||||||
expect(workspace.getActivePaneItem().getUri()).not.toBeUndefined()
|
expect(workspace.getActivePaneItem().getUri()).not.toBeUndefined()
|
||||||
|
|
||||||
# destroy all items
|
# destroy all items
|
||||||
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.resolve('file1')
|
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.getDirectories()[0]?.resolve('file1')
|
||||||
pane.destroyActiveItem()
|
pane.destroyActiveItem()
|
||||||
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.resolve('b')
|
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.getDirectories()[0]?.resolve('b')
|
||||||
pane.destroyActiveItem()
|
pane.destroyActiveItem()
|
||||||
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.resolve('a')
|
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.getDirectories()[0]?.resolve('a')
|
||||||
pane.destroyActiveItem()
|
pane.destroyActiveItem()
|
||||||
|
|
||||||
# reopens items with uris
|
# reopens items with uris
|
||||||
@@ -285,20 +285,20 @@ describe "Workspace", ->
|
|||||||
workspace.reopenItem()
|
workspace.reopenItem()
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.resolve('a')
|
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.getDirectories()[0]?.resolve('a')
|
||||||
|
|
||||||
# does not reopen items that are already open
|
# does not reopen items that are already open
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
workspace.open('b')
|
workspace.open('b')
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.resolve('b')
|
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.getDirectories()[0]?.resolve('b')
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
workspace.reopenItem()
|
workspace.reopenItem()
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.resolve('file1')
|
expect(workspace.getActivePaneItem().getUri()).toBe atom.project.getDirectories()[0]?.resolve('file1')
|
||||||
|
|
||||||
describe "::increase/decreaseFontSize()", ->
|
describe "::increase/decreaseFontSize()", ->
|
||||||
it "increases/decreases the font size without going below 1", ->
|
it "increases/decreases the font size without going below 1", ->
|
||||||
@@ -568,7 +568,7 @@ describe "Workspace", ->
|
|||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(results).toHaveLength(3)
|
expect(results).toHaveLength(3)
|
||||||
expect(results[0].filePath).toBe atom.project.resolve('a')
|
expect(results[0].filePath).toBe atom.project.getDirectories()[0]?.resolve('a')
|
||||||
expect(results[0].matches).toHaveLength(3)
|
expect(results[0].matches).toHaveLength(3)
|
||||||
expect(results[0].matches[0]).toEqual
|
expect(results[0].matches[0]).toEqual
|
||||||
matchText: 'aaa'
|
matchText: 'aaa'
|
||||||
@@ -585,7 +585,7 @@ describe "Workspace", ->
|
|||||||
expect(results.length).toBe 1
|
expect(results.length).toBe 1
|
||||||
|
|
||||||
{filePath, matches} = results[0]
|
{filePath, matches} = results[0]
|
||||||
expect(filePath).toBe atom.project.resolve('a')
|
expect(filePath).toBe atom.project.getDirectories()[0]?.resolve('a')
|
||||||
expect(matches).toHaveLength 1
|
expect(matches).toHaveLength 1
|
||||||
expect(matches[0]).toEqual
|
expect(matches[0]).toEqual
|
||||||
matchText: '$bill'
|
matchText: '$bill'
|
||||||
@@ -746,10 +746,10 @@ describe "Workspace", ->
|
|||||||
[filePath, commentFilePath, sampleContent, sampleCommentContent] = []
|
[filePath, commentFilePath, sampleContent, sampleCommentContent] = []
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
atom.project.setPaths([atom.project.resolve('../')])
|
atom.project.setPaths([atom.project.getDirectories()[0]?.resolve('../')])
|
||||||
|
|
||||||
filePath = atom.project.resolve('sample.js')
|
filePath = atom.project.getDirectories()[0]?.resolve('sample.js')
|
||||||
commentFilePath = atom.project.resolve('sample-with-comments.js')
|
commentFilePath = atom.project.getDirectories()[0]?.resolve('sample-with-comments.js')
|
||||||
sampleContent = fs.readFileSync(filePath).toString()
|
sampleContent = fs.readFileSync(filePath).toString()
|
||||||
sampleCommentContent = fs.readFileSync(commentFilePath).toString()
|
sampleCommentContent = fs.readFileSync(commentFilePath).toString()
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ describe "WorkspaceView", ->
|
|||||||
beforeEach ->
|
beforeEach ->
|
||||||
jasmine.snapshotDeprecations()
|
jasmine.snapshotDeprecations()
|
||||||
|
|
||||||
atom.project.setPaths([atom.project.resolve('dir')])
|
atom.project.setPaths([atom.project.getDirectories()[0]?.resolve('dir')])
|
||||||
pathToOpen = atom.project.resolve('a')
|
pathToOpen = atom.project.getDirectories()[0]?.resolve('a')
|
||||||
atom.workspace = new Workspace
|
atom.workspace = new Workspace
|
||||||
atom.workspaceView = atom.views.getView(atom.workspace).__spacePenView
|
atom.workspaceView = atom.views.getView(atom.workspace).__spacePenView
|
||||||
atom.workspaceView.enableKeymap()
|
atom.workspaceView.enableKeymap()
|
||||||
@@ -93,11 +93,11 @@ describe "WorkspaceView", ->
|
|||||||
editorView2 = atom.workspaceView.panes.find('atom-pane-axis.horizontal > atom-pane-axis.vertical > atom-pane atom-text-editor:eq(0)').view()
|
editorView2 = atom.workspaceView.panes.find('atom-pane-axis.horizontal > atom-pane-axis.vertical > atom-pane atom-text-editor:eq(0)').view()
|
||||||
editorView4 = atom.workspaceView.panes.find('atom-pane-axis.horizontal > atom-pane-axis.vertical > atom-pane atom-text-editor:eq(1)').view()
|
editorView4 = atom.workspaceView.panes.find('atom-pane-axis.horizontal > atom-pane-axis.vertical > atom-pane atom-text-editor:eq(1)').view()
|
||||||
|
|
||||||
expect(editorView1.getEditor().getPath()).toBe atom.project.resolve('a')
|
expect(editorView1.getEditor().getPath()).toBe atom.project.getDirectories()[0]?.resolve('a')
|
||||||
expect(editorView2.getEditor().getPath()).toBe atom.project.resolve('b')
|
expect(editorView2.getEditor().getPath()).toBe atom.project.getDirectories()[0]?.resolve('b')
|
||||||
expect(editorView3.getEditor().getPath()).toBe atom.project.resolve('../sample.js')
|
expect(editorView3.getEditor().getPath()).toBe atom.project.getDirectories()[0]?.resolve('../sample.js')
|
||||||
expect(editorView3.getEditor().getCursorScreenPosition()).toEqual [2, 4]
|
expect(editorView3.getEditor().getCursorScreenPosition()).toEqual [2, 4]
|
||||||
expect(editorView4.getEditor().getPath()).toBe atom.project.resolve('../sample.txt')
|
expect(editorView4.getEditor().getPath()).toBe atom.project.getDirectories()[0]?.resolve('../sample.txt')
|
||||||
expect(editorView4.getEditor().getCursorScreenPosition()).toEqual [0, 2]
|
expect(editorView4.getEditor().getCursorScreenPosition()).toEqual [0, 2]
|
||||||
|
|
||||||
# ensure adjust pane dimensions is called
|
# ensure adjust pane dimensions is called
|
||||||
|
|||||||
+9
-12
@@ -139,14 +139,11 @@ class Project extends Model
|
|||||||
Grim.deprecate("Use ::getDirectories instead")
|
Grim.deprecate("Use ::getDirectories instead")
|
||||||
@rootDirectory
|
@rootDirectory
|
||||||
|
|
||||||
# Public: Given a uri, this resolves it relative to the project directory. If
|
|
||||||
# the path is already absolute or if it is prefixed with a scheme, it is
|
|
||||||
# returned unchanged.
|
|
||||||
#
|
|
||||||
# * `uri` The {String} name of the path to convert.
|
|
||||||
#
|
|
||||||
# Returns a {String} or undefined if the uri is not missing or empty.
|
|
||||||
resolve: (uri) ->
|
resolve: (uri) ->
|
||||||
|
Grim.deprecate("Use `Project::getDirectories()[0]?.resolve()` instead")
|
||||||
|
@resolvePath(uri)
|
||||||
|
|
||||||
|
resolvePath: (uri) ->
|
||||||
return unless uri
|
return unless uri
|
||||||
|
|
||||||
if uri?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
|
if uri?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
|
||||||
@@ -220,14 +217,14 @@ class Project extends Model
|
|||||||
#
|
#
|
||||||
# Returns a promise that resolves to an {TextEditor}.
|
# Returns a promise that resolves to an {TextEditor}.
|
||||||
open: (filePath, options={}) ->
|
open: (filePath, options={}) ->
|
||||||
filePath = @resolve(filePath)
|
filePath = @resolvePath(filePath)
|
||||||
@bufferForPath(filePath).then (buffer) =>
|
@bufferForPath(filePath).then (buffer) =>
|
||||||
@buildEditorForBuffer(buffer, options)
|
@buildEditorForBuffer(buffer, options)
|
||||||
|
|
||||||
# Deprecated
|
# Deprecated
|
||||||
openSync: (filePath, options={}) ->
|
openSync: (filePath, options={}) ->
|
||||||
deprecate("Use Project::open instead")
|
deprecate("Use Project::open instead")
|
||||||
filePath = @resolve(filePath)
|
filePath = @resolvePath(filePath)
|
||||||
@buildEditorForBuffer(@bufferForPathSync(filePath), options)
|
@buildEditorForBuffer(@bufferForPathSync(filePath), options)
|
||||||
|
|
||||||
# Retrieves all the {TextBuffer}s in the project; that is, the
|
# Retrieves all the {TextBuffer}s in the project; that is, the
|
||||||
@@ -239,14 +236,14 @@ class Project extends Model
|
|||||||
|
|
||||||
# Is the buffer for the given path modified?
|
# Is the buffer for the given path modified?
|
||||||
isPathModified: (filePath) ->
|
isPathModified: (filePath) ->
|
||||||
@findBufferForPath(@resolve(filePath))?.isModified()
|
@findBufferForPath(@resolvePath(filePath))?.isModified()
|
||||||
|
|
||||||
findBufferForPath: (filePath) ->
|
findBufferForPath: (filePath) ->
|
||||||
_.find @buffers, (buffer) -> buffer.getPath() == filePath
|
_.find @buffers, (buffer) -> buffer.getPath() == filePath
|
||||||
|
|
||||||
# Only to be used in specs
|
# Only to be used in specs
|
||||||
bufferForPathSync: (filePath) ->
|
bufferForPathSync: (filePath) ->
|
||||||
absoluteFilePath = @resolve(filePath)
|
absoluteFilePath = @resolvePath(filePath)
|
||||||
existingBuffer = @findBufferForPath(absoluteFilePath) if filePath
|
existingBuffer = @findBufferForPath(absoluteFilePath) if filePath
|
||||||
existingBuffer ? @buildBufferSync(absoluteFilePath)
|
existingBuffer ? @buildBufferSync(absoluteFilePath)
|
||||||
|
|
||||||
@@ -259,7 +256,7 @@ class Project extends Model
|
|||||||
#
|
#
|
||||||
# Returns a promise that resolves to the {TextBuffer}.
|
# Returns a promise that resolves to the {TextBuffer}.
|
||||||
bufferForPath: (filePath) ->
|
bufferForPath: (filePath) ->
|
||||||
absoluteFilePath = @resolve(filePath)
|
absoluteFilePath = @resolvePath(filePath)
|
||||||
existingBuffer = @findBufferForPath(absoluteFilePath) if absoluteFilePath
|
existingBuffer = @findBufferForPath(absoluteFilePath) if absoluteFilePath
|
||||||
Q(existingBuffer ? @buildBuffer(absoluteFilePath))
|
Q(existingBuffer ? @buildBuffer(absoluteFilePath))
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Q = require 'q'
|
|||||||
Serializable = require 'serializable'
|
Serializable = require 'serializable'
|
||||||
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
|
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
|
||||||
Grim = require 'grim'
|
Grim = require 'grim'
|
||||||
|
fs = require 'fs-plus'
|
||||||
TextEditor = require './text-editor'
|
TextEditor = require './text-editor'
|
||||||
PaneContainer = require './pane-container'
|
PaneContainer = require './pane-container'
|
||||||
Pane = require './pane'
|
Pane = require './pane'
|
||||||
@@ -383,7 +384,7 @@ class Workspace extends Model
|
|||||||
open: (uri, options={}) ->
|
open: (uri, options={}) ->
|
||||||
searchAllPanes = options.searchAllPanes
|
searchAllPanes = options.searchAllPanes
|
||||||
split = options.split
|
split = options.split
|
||||||
uri = atom.project.resolve(uri)
|
uri = atom.project.resolvePath(uri)
|
||||||
|
|
||||||
pane = @paneContainer.paneForUri(uri) if searchAllPanes
|
pane = @paneContainer.paneForUri(uri) if searchAllPanes
|
||||||
pane ?= switch split
|
pane ?= switch split
|
||||||
@@ -422,8 +423,7 @@ class Workspace extends Model
|
|||||||
{initialLine, initialColumn} = options
|
{initialLine, initialColumn} = options
|
||||||
activatePane = options.activatePane ? true
|
activatePane = options.activatePane ? true
|
||||||
|
|
||||||
uri = atom.project.resolve(uri)
|
uri = atom.project.resolvePath(uri)
|
||||||
|
|
||||||
item = @getActivePane().itemForUri(uri)
|
item = @getActivePane().itemForUri(uri)
|
||||||
if uri
|
if uri
|
||||||
item ?= opener(uri, options) for opener in @getOpeners() when !item
|
item ?= opener(uri, options) for opener in @getOpeners() when !item
|
||||||
@@ -445,7 +445,7 @@ class Workspace extends Model
|
|||||||
|
|
||||||
if uri?
|
if uri?
|
||||||
item = pane.itemForUri(uri)
|
item = pane.itemForUri(uri)
|
||||||
item ?= opener(atom.project.resolve(uri), options) for opener in @getOpeners() when !item
|
item ?= opener(uri, options) for opener in @getOpeners() when !item
|
||||||
item ?= atom.project.open(uri, options)
|
item ?= atom.project.open(uri, options)
|
||||||
|
|
||||||
Q(item)
|
Q(item)
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário