mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Fix breakages due to save method moving to Pane (except saveAll specs)
This commit is contained in:
committed by
probablycorey
parent
3f9ee08e76
commit
685df18a3a
@@ -139,7 +139,6 @@ describe "Editor", ->
|
||||
expect(editor.verticalScrollbar.prop('scrollHeight')).toBe previousScrollHeight
|
||||
expect(editor.scrollTop()).toBe previousScrollTop
|
||||
expect(editor.scrollView.scrollLeft()).toBe previousScrollLeft
|
||||
console.log editor.getCursorView().css('left')
|
||||
expect(editor.getCursorView().position()).toEqual { top: 3 * editor.lineHeight, left: 5 * editor.charWidth }
|
||||
editor.insertText("goodbye")
|
||||
expect(editor.lineElementForScreenRow(3).text()).toMatch /^ vgoodbyear/
|
||||
@@ -162,54 +161,6 @@ describe "Editor", ->
|
||||
runs ->
|
||||
expect(atom.confirm).toHaveBeenCalled()
|
||||
|
||||
describe ".save()", ->
|
||||
describe "when the current buffer has a path", ->
|
||||
tempFilePath = null
|
||||
|
||||
beforeEach ->
|
||||
project.setPath('/tmp')
|
||||
tempFilePath = '/tmp/atom-temp.txt'
|
||||
fs.write(tempFilePath, "")
|
||||
editor.edit(project.buildEditSession(tempFilePath))
|
||||
|
||||
afterEach ->
|
||||
expect(fs.remove(tempFilePath))
|
||||
|
||||
it "saves the current buffer to disk", ->
|
||||
editor.getBuffer().setText 'Edited!'
|
||||
expect(fs.read(tempFilePath)).not.toBe "Edited!"
|
||||
|
||||
editor.save()
|
||||
|
||||
expect(fs.exists(tempFilePath)).toBeTruthy()
|
||||
expect(fs.read(tempFilePath)).toBe 'Edited!'
|
||||
|
||||
describe "when the current buffer has no path", ->
|
||||
selectedFilePath = null
|
||||
beforeEach ->
|
||||
editor.edit(project.buildEditSession())
|
||||
editor.getBuffer().setText 'Save me to a new path'
|
||||
spyOn(atom, 'showSaveDialog').andCallFake (callback) -> callback(selectedFilePath)
|
||||
|
||||
it "presents a 'save as' dialog", ->
|
||||
editor.save()
|
||||
expect(atom.showSaveDialog).toHaveBeenCalled()
|
||||
|
||||
describe "when a path is chosen", ->
|
||||
it "saves the buffer to the chosen path", ->
|
||||
selectedFilePath = '/tmp/temp.txt'
|
||||
|
||||
editor.save()
|
||||
|
||||
expect(fs.exists(selectedFilePath)).toBeTruthy()
|
||||
expect(fs.read(selectedFilePath)).toBe 'Save me to a new path'
|
||||
|
||||
describe "when dialog is cancelled", ->
|
||||
it "does not save the buffer", ->
|
||||
selectedFilePath = null
|
||||
editor.save()
|
||||
expect(fs.exists(selectedFilePath)).toBeFalsy()
|
||||
|
||||
describe ".scrollTop(n)", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom(heightInLines: 5)
|
||||
@@ -2025,7 +1976,7 @@ describe "Editor", ->
|
||||
|
||||
it "restores the contents of the editor to the HEAD revision", ->
|
||||
editor.setText('')
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
|
||||
fileChangeHandler = jasmine.createSpy('fileChange')
|
||||
editor.getBuffer().file.on 'contents-changed', fileChangeHandler
|
||||
|
||||
@@ -348,7 +348,7 @@ class Editor extends View
|
||||
|
||||
@hiddenInput.on 'focusout', =>
|
||||
@isFocused = false
|
||||
@autosave() if config.get "editor.autosave"
|
||||
# @autosave() if config.get "editor.autosave"
|
||||
@removeClass 'is-focused'
|
||||
|
||||
@underlayer.on 'click', (e) =>
|
||||
@@ -456,7 +456,7 @@ class Editor extends View
|
||||
return if editSession is @activeEditSession
|
||||
|
||||
if @activeEditSession
|
||||
@autosave() if config.get "editor.autosave"
|
||||
# @autosave() if config.get "editor.autosave"
|
||||
@saveScrollPositionForActiveEditSession()
|
||||
@activeEditSession.off(".editor")
|
||||
|
||||
@@ -609,8 +609,8 @@ class Editor extends View
|
||||
@removeClass 'soft-wrap'
|
||||
$(window).off 'resize', @_setSoftWrapColumn
|
||||
|
||||
autosave: ->
|
||||
@save() if @getPath()?
|
||||
# autosave: ->
|
||||
# @save() if @getPath()?
|
||||
|
||||
setFontSize: (fontSize) ->
|
||||
headTag = $("head")
|
||||
|
||||
@@ -63,7 +63,7 @@ describe "StatusBar", ->
|
||||
editor.insertText("\n")
|
||||
advanceClock(buffer.stoppedChangingDelay)
|
||||
expect(statusBar.bufferModified.text()).toBe '*'
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(statusBar.bufferModified.text()).toBe ''
|
||||
|
||||
it "disables the buffer modified indicator if the content matches again", ->
|
||||
|
||||
@@ -23,7 +23,7 @@ describe "StripTrailingWhitespace", ->
|
||||
|
||||
# works for buffers that are already open when extension is initialized
|
||||
editor.insertText("foo \nbar\t \n\nbaz")
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "foo\nbar\n\nbaz"
|
||||
|
||||
# works for buffers that are opened after extension is initialized
|
||||
@@ -47,25 +47,25 @@ describe "StripTrailingWhitespace", ->
|
||||
|
||||
it "adds a trailing newline when there is no trailing newline", ->
|
||||
editor.insertText "foo"
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "foo\n"
|
||||
|
||||
it "removes extra trailing newlines and only keeps one", ->
|
||||
editor.insertText "foo\n\n\n\n"
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "foo\n"
|
||||
|
||||
it "leaves a buffer with a single trailing newline untouched", ->
|
||||
editor.insertText "foo\nbar\n"
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "foo\nbar\n"
|
||||
|
||||
it "leaves an empty buffer untouched", ->
|
||||
editor.insertText ""
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe ""
|
||||
|
||||
it "leaves a buffer that is a single newline untouched", ->
|
||||
editor.insertText "\n"
|
||||
editor.save()
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "\n"
|
||||
|
||||
Reference in New Issue
Block a user