mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Rename buildEditSessionForPath to buildEditSession
Since this is the more external method, having a shorter name is more convenient. The former `buildEditSession` method took a Buffer, and is now called `buildEditSessionForBuffer`.
This commit is contained in:
committed by
probablycorey
parent
9fe1be7fe0
commit
beaeac4425
@@ -107,7 +107,7 @@ describe "TokenizedBuffer.", ->
|
||||
[languageMode, buffer] = []
|
||||
|
||||
beforeEach ->
|
||||
editSession = benchmarkFixturesProject.buildEditSessionForPath('medium.coffee')
|
||||
editSession = benchmarkFixturesProject.buildEditSession('medium.coffee')
|
||||
{ languageMode, buffer } = editSession
|
||||
|
||||
benchmark "construction", 20, ->
|
||||
|
||||
@@ -6,7 +6,7 @@ describe "DisplayBuffer", ->
|
||||
[editSession, displayBuffer, buffer, changeHandler, tabLength] = []
|
||||
beforeEach ->
|
||||
tabLength = 2
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js', { tabLength })
|
||||
editSession = fixturesProject.buildEditSession('sample.js', { tabLength })
|
||||
{ buffer, displayBuffer } = editSession
|
||||
changeHandler = jasmine.createSpy 'changeHandler'
|
||||
displayBuffer.on 'changed', changeHandler
|
||||
@@ -228,7 +228,7 @@ describe "DisplayBuffer", ->
|
||||
editSession2 = null
|
||||
|
||||
beforeEach ->
|
||||
editSession2 = fixturesProject.buildEditSessionForPath('two-hundred.txt')
|
||||
editSession2 = fixturesProject.buildEditSession('two-hundred.txt')
|
||||
{ buffer, displayBuffer } = editSession2
|
||||
displayBuffer.on 'changed', changeHandler
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ describe "EditSession", ->
|
||||
buffer.setText(buffer.getText().replace(/[ ]{2}/g, "\t"))
|
||||
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
lineLengths = buffer.getLines().map (line) -> line.length
|
||||
|
||||
@@ -1715,7 +1715,7 @@ describe "EditSession", ->
|
||||
|
||||
it "does not explode if the current language mode has no comment regex", ->
|
||||
editSession.destroy()
|
||||
editSession = fixturesProject.buildEditSessionForPath(null, autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession(null, autoIndent: false)
|
||||
editSession.setSelectedBufferRange([[4, 5], [4, 5]])
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
|
||||
@@ -1793,7 +1793,7 @@ describe "EditSession", ->
|
||||
expect(editSession.getSelectedBufferRanges()).toEqual [[[1, 6], [1, 6]], [[1, 18], [1, 18]]]
|
||||
|
||||
it "restores selected ranges even when the change occurred in another edit session", ->
|
||||
otherEditSession = fixturesProject.buildEditSessionForPath(editSession.getPath())
|
||||
otherEditSession = fixturesProject.buildEditSession(editSession.getPath())
|
||||
otherEditSession.setSelectedBufferRange([[2, 2], [3, 3]])
|
||||
otherEditSession.delete()
|
||||
|
||||
@@ -1986,13 +1986,13 @@ describe "EditSession", ->
|
||||
|
||||
describe "soft-tabs detection", ->
|
||||
it "assign soft / hard tabs based on the contents of the buffer, or uses the default if unknown", ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js', softTabs: false)
|
||||
editSession = fixturesProject.buildEditSession('sample.js', softTabs: false)
|
||||
expect(editSession.softTabs).toBeTruthy()
|
||||
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample-with-tabs.coffee', softTabs: true)
|
||||
editSession = fixturesProject.buildEditSession('sample-with-tabs.coffee', softTabs: true)
|
||||
expect(editSession.softTabs).toBeFalsy()
|
||||
|
||||
editSession = fixturesProject.buildEditSessionForPath(null, softTabs: false)
|
||||
editSession = fixturesProject.buildEditSession(null, softTabs: false)
|
||||
expect(editSession.softTabs).toBeFalsy()
|
||||
|
||||
describe ".indentLevelForLine(line)", ->
|
||||
|
||||
@@ -14,7 +14,7 @@ describe "Editor", ->
|
||||
|
||||
getLineHeight = ->
|
||||
return cachedLineHeight if cachedLineHeight?
|
||||
editorForMeasurement = new Editor(editSession: project.buildEditSessionForPath('sample.js'))
|
||||
editorForMeasurement = new Editor(editSession: project.buildEditSession('sample.js'))
|
||||
editorForMeasurement.attachToDom()
|
||||
cachedLineHeight = editorForMeasurement.lineHeight
|
||||
editorForMeasurement.remove()
|
||||
@@ -46,7 +46,7 @@ describe "Editor", ->
|
||||
rootView.height(8 * editor.lineHeight)
|
||||
rootView.width(50 * editor.charWidth)
|
||||
|
||||
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
|
||||
editor.edit(project.buildEditSession('two-hundred.txt'))
|
||||
editor.setCursorScreenPosition([5, 1])
|
||||
editor.scrollTop(1.5 * editor.lineHeight)
|
||||
editor.scrollView.scrollLeft(44)
|
||||
@@ -75,7 +75,7 @@ describe "Editor", ->
|
||||
it "does not blow up if no file exists for a previous edit session, but prints a warning", ->
|
||||
spyOn(console, 'warn')
|
||||
fs.write('/tmp/delete-me')
|
||||
editor.edit(project.buildEditSessionForPath('/tmp/delete-me'))
|
||||
editor.edit(project.buildEditSession('/tmp/delete-me'))
|
||||
fs.remove('/tmp/delete-me')
|
||||
newEditor = editor.copy()
|
||||
expect(console.warn).toHaveBeenCalled()
|
||||
@@ -117,7 +117,7 @@ describe "Editor", ->
|
||||
it "triggers an alert", ->
|
||||
path = "/tmp/atom-changed-file.txt"
|
||||
fs.write(path, "")
|
||||
editSession = project.buildEditSessionForPath(path)
|
||||
editSession = project.buildEditSession(path)
|
||||
editor.edit(editSession)
|
||||
editor.insertText("now the buffer is modified")
|
||||
|
||||
@@ -138,7 +138,7 @@ describe "Editor", ->
|
||||
it "removes subscriptions from all edit session buffers", ->
|
||||
editSession1 = editor.activeEditSession
|
||||
subscriberCount1 = editSession1.buffer.subscriptionCount()
|
||||
editSession2 = project.buildEditSessionForPath(project.resolve('sample.txt'))
|
||||
editSession2 = project.buildEditSession(project.resolve('sample.txt'))
|
||||
expect(subscriberCount1).toBeGreaterThan 1
|
||||
|
||||
editor.edit(editSession2)
|
||||
@@ -151,17 +151,17 @@ describe "Editor", ->
|
||||
|
||||
describe "when 'close' is triggered", ->
|
||||
it "adds a closed session path to the array", ->
|
||||
editor.edit(project.buildEditSessionForPath())
|
||||
editor.edit(project.buildEditSession())
|
||||
editSession = editor.activeEditSession
|
||||
expect(editor.closedEditSessions.length).toBe 0
|
||||
editor.trigger "core:close"
|
||||
expect(editor.closedEditSessions.length).toBe 0
|
||||
editor.edit(project.buildEditSessionForPath(project.resolve('sample.txt')))
|
||||
editor.edit(project.buildEditSession(project.resolve('sample.txt')))
|
||||
editor.trigger "core:close"
|
||||
expect(editor.closedEditSessions.length).toBe 1
|
||||
|
||||
it "closes the active edit session and loads next edit session", ->
|
||||
editor.edit(project.buildEditSessionForPath())
|
||||
editor.edit(project.buildEditSession())
|
||||
editSession = editor.activeEditSession
|
||||
spyOn(editSession.buffer, 'isModified').andReturn false
|
||||
spyOn(editSession, 'destroy').andCallThrough()
|
||||
@@ -172,7 +172,7 @@ describe "Editor", ->
|
||||
expect(editor.getBuffer()).toBe buffer
|
||||
|
||||
it "triggers the 'editor:edit-session-removed' event with the edit session and its former index", ->
|
||||
editor.edit(project.buildEditSessionForPath())
|
||||
editor.edit(project.buildEditSession())
|
||||
editSession = editor.activeEditSession
|
||||
index = editor.getActiveEditSessionIndex()
|
||||
spyOn(editSession.buffer, 'isModified').andReturn false
|
||||
@@ -220,7 +220,7 @@ describe "Editor", ->
|
||||
otherEditSession = null
|
||||
|
||||
beforeEach ->
|
||||
otherEditSession = project.buildEditSessionForPath()
|
||||
otherEditSession = project.buildEditSession()
|
||||
|
||||
describe "when the edit session wasn't previously assigned to this editor", ->
|
||||
it "adds edit session to editor and triggers the 'editor:edit-session-added' event", ->
|
||||
@@ -257,11 +257,11 @@ describe "Editor", ->
|
||||
expect(editor.lineElementForScreenRow(0).text()).toBe 'def'
|
||||
|
||||
it "removes the opened session from the closed sessions array", ->
|
||||
editor.edit(project.buildEditSessionForPath('sample.txt'))
|
||||
editor.edit(project.buildEditSession('sample.txt'))
|
||||
expect(editor.closedEditSessions.length).toBe 0
|
||||
editor.trigger "core:close"
|
||||
expect(editor.closedEditSessions.length).toBe 1
|
||||
editor.edit(project.buildEditSessionForPath('sample.txt'))
|
||||
editor.edit(project.buildEditSession('sample.txt'))
|
||||
expect(editor.closedEditSessions.length).toBe 0
|
||||
|
||||
describe "switching edit sessions", ->
|
||||
@@ -270,10 +270,10 @@ describe "Editor", ->
|
||||
beforeEach ->
|
||||
session0 = editor.activeEditSession
|
||||
|
||||
editor.edit(project.buildEditSessionForPath('sample.txt'))
|
||||
editor.edit(project.buildEditSession('sample.txt'))
|
||||
session1 = editor.activeEditSession
|
||||
|
||||
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
|
||||
editor.edit(project.buildEditSession('two-hundred.txt'))
|
||||
session2 = editor.activeEditSession
|
||||
|
||||
describe ".setActiveEditSessionIndex(index)", ->
|
||||
@@ -304,7 +304,7 @@ describe "Editor", ->
|
||||
it "triggers alert if edit session's buffer goes into conflict with changes on disk", ->
|
||||
path = "/tmp/atom-changed-file.txt"
|
||||
fs.write(path, "")
|
||||
editSession = project.buildEditSessionForPath(path)
|
||||
editSession = project.buildEditSession(path)
|
||||
editor.edit editSession
|
||||
editSession.insertText("a buffer change")
|
||||
|
||||
@@ -379,7 +379,7 @@ describe "Editor", ->
|
||||
describe "when the current buffer has no path", ->
|
||||
selectedFilePath = null
|
||||
beforeEach ->
|
||||
editor.edit(project.buildEditSessionForPath())
|
||||
editor.edit(project.buildEditSession())
|
||||
|
||||
expect(editor.getPath()).toBeUndefined()
|
||||
editor.getBuffer().setText 'Save me to a new path'
|
||||
@@ -459,7 +459,7 @@ describe "Editor", ->
|
||||
spyOn(editor, 'pane').andReturn(fakePane)
|
||||
|
||||
it "calls the corresponding split method on the containing pane with a new editor containing a copy of the active edit session", ->
|
||||
editor.edit project.buildEditSessionForPath("sample.txt")
|
||||
editor.edit project.buildEditSession("sample.txt")
|
||||
editor.splitUp()
|
||||
expect(fakePane.splitUp).toHaveBeenCalled()
|
||||
[newEditor] = fakePane.splitUp.argsForCall[0]
|
||||
@@ -506,7 +506,7 @@ describe "Editor", ->
|
||||
it "emits event when editor receives a new buffer", ->
|
||||
eventHandler = jasmine.createSpy('eventHandler')
|
||||
editor.on 'editor:path-changed', eventHandler
|
||||
editor.edit(project.buildEditSessionForPath(path))
|
||||
editor.edit(project.buildEditSession(path))
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
it "stops listening to events on previously set buffers", ->
|
||||
@@ -514,7 +514,7 @@ describe "Editor", ->
|
||||
oldBuffer = editor.getBuffer()
|
||||
editor.on 'editor:path-changed', eventHandler
|
||||
|
||||
editor.edit(project.buildEditSessionForPath(path))
|
||||
editor.edit(project.buildEditSession(path))
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
eventHandler.reset()
|
||||
@@ -1374,7 +1374,7 @@ describe "Editor", ->
|
||||
expect(editor.bufferPositionForScreenPosition(editor.getCursorScreenPosition())).toEqual [3, 60]
|
||||
|
||||
it "does not wrap the lines of any newly assigned buffers", ->
|
||||
otherEditSession = project.buildEditSessionForPath()
|
||||
otherEditSession = project.buildEditSession()
|
||||
otherEditSession.buffer.setText([1..100].join(''))
|
||||
editor.edit(otherEditSession)
|
||||
expect(editor.renderedLines.find('.line').length).toBe(1)
|
||||
@@ -1410,7 +1410,7 @@ describe "Editor", ->
|
||||
expect(editor.getCursorScreenPosition()).toEqual [11, 0]
|
||||
|
||||
it "calls .setSoftWrapColumn() when the editor is attached because now its dimensions are available to calculate it", ->
|
||||
otherEditor = new Editor(editSession: project.buildEditSessionForPath('sample.js'))
|
||||
otherEditor = new Editor(editSession: project.buildEditSession('sample.js'))
|
||||
spyOn(otherEditor, 'setSoftWrapColumn')
|
||||
|
||||
otherEditor.setSoftWrap(true)
|
||||
@@ -1706,7 +1706,7 @@ describe "Editor", ->
|
||||
|
||||
describe "when autoscrolling at the end of the document", ->
|
||||
it "renders lines properly", ->
|
||||
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
|
||||
editor.edit(project.buildEditSession('two-hundred.txt'))
|
||||
editor.attachToDom(heightInLines: 5.5)
|
||||
|
||||
expect(editor.renderedLines.find('.line').length).toBe 8
|
||||
@@ -1987,7 +1987,7 @@ describe "Editor", ->
|
||||
|
||||
describe "when the switching from an edit session for a long buffer to an edit session for a short buffer", ->
|
||||
it "updates the line numbers to reflect the shorter buffer", ->
|
||||
editor.edit(fixturesProject.buildEditSessionForPath(null))
|
||||
editor.edit(fixturesProject.buildEditSession(null))
|
||||
expect(editor.gutter.lineNumbers.find('.line-number').length).toBe 1
|
||||
|
||||
editor.setActiveEditSessionIndex(0)
|
||||
@@ -2121,7 +2121,7 @@ describe "Editor", ->
|
||||
|
||||
describe "folding", ->
|
||||
beforeEach ->
|
||||
editSession = project.buildEditSessionForPath('two-hundred.txt')
|
||||
editSession = project.buildEditSession('two-hundred.txt')
|
||||
buffer = editSession.buffer
|
||||
editor.edit(editSession)
|
||||
editor.attachToDom()
|
||||
@@ -2212,9 +2212,9 @@ describe "Editor", ->
|
||||
|
||||
describe ".getOpenBufferPaths()", ->
|
||||
it "returns the paths of all non-anonymous buffers with edit sessions on this editor", ->
|
||||
editor.edit(project.buildEditSessionForPath('sample.txt'))
|
||||
editor.edit(project.buildEditSessionForPath('two-hundred.txt'))
|
||||
editor.edit(project.buildEditSessionForPath())
|
||||
editor.edit(project.buildEditSession('sample.txt'))
|
||||
editor.edit(project.buildEditSession('two-hundred.txt'))
|
||||
editor.edit(project.buildEditSession())
|
||||
paths = editor.getOpenBufferPaths().map (path) -> project.relativize(path)
|
||||
expect(paths).toEqual = ['sample.js', 'sample.txt', 'two-hundred.txt']
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ describe "LanguageMode", ->
|
||||
|
||||
describe "common behavior", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
|
||||
{ buffer, languageMode } = editSession
|
||||
|
||||
describe "language detection", ->
|
||||
it "uses the file name as the file type if it has no extension", ->
|
||||
jsEditSession = fixturesProject.buildEditSessionForPath('js', autoIndent: false)
|
||||
jsEditSession = fixturesProject.buildEditSession('js', autoIndent: false)
|
||||
expect(jsEditSession.languageMode.grammar.name).toBe "JavaScript"
|
||||
jsEditSession.destroy()
|
||||
|
||||
describe "javascript", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
|
||||
{ buffer, languageMode } = editSession
|
||||
|
||||
describe ".toggleLineCommentsForBufferRows(start, end)", ->
|
||||
@@ -63,7 +63,7 @@ describe "LanguageMode", ->
|
||||
|
||||
describe "coffeescript", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('coffee.coffee', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('coffee.coffee', autoIndent: false)
|
||||
{ buffer, languageMode } = editSession
|
||||
|
||||
describe ".toggleLineCommentsForBufferRows(start, end)", ->
|
||||
@@ -98,7 +98,7 @@ describe "LanguageMode", ->
|
||||
|
||||
describe "css", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('css.css', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('css.css', autoIndent: false)
|
||||
{ buffer, languageMode } = editSession
|
||||
|
||||
describe ".toggleLineCommentsForBufferRows(start, end)", ->
|
||||
|
||||
@@ -12,8 +12,8 @@ describe "Project", ->
|
||||
|
||||
describe "when editSession is destroyed", ->
|
||||
it "removes edit session and calls destroy on buffer (if buffer is not referenced by other edit sessions)", ->
|
||||
editSession = project.buildEditSessionForPath("a")
|
||||
anotherEditSession = project.buildEditSessionForPath("a")
|
||||
editSession = project.buildEditSession("a")
|
||||
anotherEditSession = project.buildEditSession("a")
|
||||
|
||||
expect(project.editSessions.length).toBe 2
|
||||
expect(editSession.buffer).toBe anotherEditSession.buffer
|
||||
@@ -24,7 +24,7 @@ describe "Project", ->
|
||||
anotherEditSession.destroy()
|
||||
expect(project.editSessions.length).toBe 0
|
||||
|
||||
describe ".buildEditSessionForPath(path)", ->
|
||||
describe ".buildEditSession(path)", ->
|
||||
[absolutePath, newBufferHandler, newEditSessionHandler] = []
|
||||
beforeEach ->
|
||||
absolutePath = require.resolve('fixtures/dir/a')
|
||||
@@ -35,30 +35,30 @@ describe "Project", ->
|
||||
|
||||
describe "when given an absolute path that hasn't been opened previously", ->
|
||||
it "returns a new edit session for the given path and emits 'buffer-created' and 'edit-session-created' events", ->
|
||||
editSession = project.buildEditSessionForPath(absolutePath)
|
||||
editSession = project.buildEditSession(absolutePath)
|
||||
expect(editSession.buffer.getPath()).toBe absolutePath
|
||||
expect(newBufferHandler).toHaveBeenCalledWith editSession.buffer
|
||||
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
||||
|
||||
describe "when given a relative path that hasn't been opened previously", ->
|
||||
it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created' and 'edit-session-created' events", ->
|
||||
editSession = project.buildEditSessionForPath('a')
|
||||
editSession = project.buildEditSession('a')
|
||||
expect(editSession.buffer.getPath()).toBe absolutePath
|
||||
expect(newBufferHandler).toHaveBeenCalledWith editSession.buffer
|
||||
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
||||
|
||||
describe "when passed the path to a buffer that has already been opened", ->
|
||||
it "returns a new edit session containing previously opened buffer and emits a 'edit-session-created' event", ->
|
||||
editSession = project.buildEditSessionForPath(absolutePath)
|
||||
editSession = project.buildEditSession(absolutePath)
|
||||
newBufferHandler.reset()
|
||||
expect(project.buildEditSessionForPath(absolutePath).buffer).toBe editSession.buffer
|
||||
expect(project.buildEditSessionForPath('a').buffer).toBe editSession.buffer
|
||||
expect(project.buildEditSession(absolutePath).buffer).toBe editSession.buffer
|
||||
expect(project.buildEditSession('a').buffer).toBe editSession.buffer
|
||||
expect(newBufferHandler).not.toHaveBeenCalled()
|
||||
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
||||
|
||||
describe "when not passed a path", ->
|
||||
it "returns a new edit session and emits 'buffer-created' and 'edit-session-created' events", ->
|
||||
editSession = project.buildEditSessionForPath()
|
||||
editSession = project.buildEditSession()
|
||||
expect(editSession.buffer.getPath()).toBeUndefined()
|
||||
expect(newBufferHandler).toHaveBeenCalledWith(editSession.buffer)
|
||||
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
||||
|
||||
@@ -43,10 +43,10 @@ describe "RootView", ->
|
||||
editor2 = editor1.splitRight()
|
||||
editor3 = editor2.splitRight()
|
||||
editor4 = editor2.splitDown()
|
||||
editor2.edit(project.buildEditSessionForPath('b'))
|
||||
editor3.edit(project.buildEditSessionForPath('../sample.js'))
|
||||
editor2.edit(project.buildEditSession('b'))
|
||||
editor3.edit(project.buildEditSession('../sample.js'))
|
||||
editor3.setCursorScreenPosition([2, 4])
|
||||
editor4.edit(project.buildEditSessionForPath('../sample.txt'))
|
||||
editor4.edit(project.buildEditSession('../sample.txt'))
|
||||
editor4.setCursorScreenPosition([0, 2])
|
||||
rootView.attachToDom()
|
||||
editor2.focus()
|
||||
@@ -404,7 +404,7 @@ describe "RootView", ->
|
||||
editor2 = rootView.getActiveEditor().splitLeft()
|
||||
|
||||
path = project.resolve('b')
|
||||
editor2.edit(project.buildEditSessionForPath(path))
|
||||
editor2.edit(project.buildEditSession(path))
|
||||
expect(pathChangeHandler).toHaveBeenCalled()
|
||||
expect(rootView.getTitle()).toBe "#{fs.base(editor2.getPath())} – #{project.getPath()}"
|
||||
|
||||
@@ -584,7 +584,7 @@ describe "RootView", ->
|
||||
expect(buffer1.isModified()).toBe(true)
|
||||
|
||||
editor2 = editor1.splitRight()
|
||||
editor2.edit(project.buildEditSessionForPath('atom-temp2.txt'))
|
||||
editor2.edit(project.buildEditSession('atom-temp2.txt'))
|
||||
buffer2 = editor2.activeEditSession.buffer
|
||||
expect(buffer2.getText()).toBe("file2")
|
||||
expect(buffer2.isModified()).toBe(false)
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
describe "when the buffer contains soft-tabs", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('sample.js', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
@@ -299,7 +299,7 @@ describe "TokenizedBuffer", ->
|
||||
describe "when the buffer contains hard-tabs", ->
|
||||
beforeEach ->
|
||||
tabLength = 2
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample-with-tabs.coffee', { tabLength })
|
||||
editSession = fixturesProject.buildEditSession('sample-with-tabs.coffee', { tabLength })
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
@@ -328,7 +328,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
describe "when a Git commit message file is tokenized", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('COMMIT_EDITMSG', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('COMMIT_EDITMSG', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
@@ -355,7 +355,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
describe "when a C++ source file is tokenized", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('includes.cc', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('includes.cc', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
@@ -386,7 +386,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
describe "when a Ruby source file is tokenized", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('hello.rb', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('hello.rb', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
@@ -403,7 +403,7 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
describe "when an Objective-C source file is tokenized", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('function.mm', autoIndent: false)
|
||||
editSession = fixturesProject.buildEditSession('function.mm', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
|
||||
@@ -16,10 +16,10 @@ class EditSession
|
||||
|
||||
@deserialize: (state, project) ->
|
||||
if fs.exists(state.buffer)
|
||||
session = project.buildEditSessionForPath(state.buffer)
|
||||
session = project.buildEditSession(state.buffer)
|
||||
else
|
||||
console.warn "Could not build edit session for path '#{state.buffer}' because that file no longer exists" if state.buffer
|
||||
session = project.buildEditSessionForPath(null)
|
||||
session = project.buildEditSession(null)
|
||||
session.setScrollTop(state.scrollTop)
|
||||
session.setScrollLeft(state.scrollLeft)
|
||||
session.setCursorScreenPosition(state.cursorScreenPosition)
|
||||
|
||||
@@ -95,10 +95,10 @@ class Project
|
||||
getSoftWrap: -> @softWrap
|
||||
setSoftWrap: (@softWrap) ->
|
||||
|
||||
buildEditSessionForPath: (filePath, editSessionOptions={}) ->
|
||||
@buildEditSession(@bufferForPath(filePath), editSessionOptions)
|
||||
buildEditSession: (filePath, editSessionOptions={}) ->
|
||||
@buildEditSessionForBuffer(@bufferForPath(filePath), editSessionOptions)
|
||||
|
||||
buildEditSession: (buffer, editSessionOptions) ->
|
||||
buildEditSessionForBuffer: (buffer, editSessionOptions) ->
|
||||
options = _.extend(@defaultEditSessionOptions(), editSessionOptions)
|
||||
options.project = this
|
||||
options.buffer = buffer
|
||||
|
||||
@@ -95,7 +95,7 @@ class RootView extends View
|
||||
allowActiveEditorChange = options.allowActiveEditorChange ? false
|
||||
|
||||
unless editSession = @openInExistingEditor(path, allowActiveEditorChange, changeFocus)
|
||||
editSession = project.buildEditSessionForPath(path)
|
||||
editSession = project.buildEditSession(path)
|
||||
editor = new Editor({editSession})
|
||||
pane = new Pane(editor)
|
||||
@panes.append(pane)
|
||||
@@ -121,7 +121,7 @@ class RootView extends View
|
||||
@makeEditorActive(editor, changeFocus)
|
||||
return editSession
|
||||
|
||||
editSession = project.buildEditSessionForPath(path)
|
||||
editSession = project.buildEditSession(path)
|
||||
activeEditor.edit(editSession)
|
||||
editSession
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ describe "AutocompleteView", ->
|
||||
|
||||
beforeEach ->
|
||||
window.rootView = new RootView
|
||||
editor = new Editor(editSession: fixturesProject.buildEditSessionForPath('sample.js'))
|
||||
editor = new Editor(editSession: fixturesProject.buildEditSession('sample.js'))
|
||||
window.loadPackage('autocomplete')
|
||||
autocomplete = new AutocompleteView(editor)
|
||||
miniEditor = autocomplete.miniEditor
|
||||
|
||||
@@ -11,7 +11,7 @@ describe "CommandInterpreter", ->
|
||||
beforeEach ->
|
||||
project = new Project(fixturesProject.resolve('dir/'))
|
||||
interpreter = new CommandInterpreter(fixturesProject)
|
||||
editSession = fixturesProject.buildEditSessionForPath('sample.js')
|
||||
editSession = fixturesProject.buildEditSession('sample.js')
|
||||
buffer = editSession.buffer
|
||||
|
||||
afterEach ->
|
||||
@@ -428,7 +428,7 @@ describe "CommandInterpreter", ->
|
||||
runs ->
|
||||
expect(operationsToPreview.length).toBeGreaterThan 3
|
||||
for operation in operationsToPreview
|
||||
editSession = project.buildEditSessionForPath(operation.getPath())
|
||||
editSession = project.buildEditSession(operation.getPath())
|
||||
editSession.setSelectedBufferRange(operation.execute(editSession))
|
||||
expect(editSession.getSelectedText()).toMatch /a+/
|
||||
editSession.destroy()
|
||||
|
||||
@@ -73,7 +73,7 @@ class FuzzyFinderView extends SelectList
|
||||
|
||||
editor = rootView.getActiveEditor()
|
||||
if editor
|
||||
fn(editor, project.buildEditSessionForPath(path))
|
||||
fn(editor, project.buildEditSession(path))
|
||||
else
|
||||
@openPath(path)
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ describe 'FuzzyFinder', ->
|
||||
describe "when the active editor only contains edit sessions for anonymous buffers", ->
|
||||
it "does not open", ->
|
||||
editor = rootView.getActiveEditor()
|
||||
editor.edit(project.buildEditSessionForPath())
|
||||
editor.edit(project.buildEditSession())
|
||||
editor.loadPreviousEditSession()
|
||||
editor.destroyActiveEditSession()
|
||||
expect(editor.getOpenBufferPaths().length).toBe 0
|
||||
|
||||
Reference in New Issue
Block a user