Purge autosave from Atom source

This commit is contained in:
probablycorey 2013-10-28 15:51:14 -07:00
parent b1f5d1e276
commit e7e28b568b
5 changed files with 3 additions and 79 deletions

View File

@ -63,7 +63,6 @@ namespaces: `core` and `editor`.
### Configuration Key Reference
- `core`
- `autosave`: Save a buffer when its view loses focus
- `disabledPackages`: An array of package names to disable
- `excludeVcsIgnoredPaths`: Don't search within files specified by _.gitignore_
- `hideGitIgnoredFiles`: Whether files in the _.gitignore_ should be hidden

View File

@ -7,7 +7,7 @@ read config settings. You can read a value from `config` with `config.get`:
```coffeescript
# read a value with `config.get`
@autosave() if config.get "core.autosave"
@showInvisibles() if config.get "edtior.showInvisibles"
```
Or you can use `observeConfig` to track changes from a view object.
@ -47,7 +47,7 @@ the following way:
```coffeescript
# basic key update
config.set("core.autosave", true)
config.set("core.showInvisibles", true)
config.pushAtKeyPath("core.disabledPackages", "wrap-guide")
```

View File

@ -659,68 +659,6 @@ describe "Pane", ->
expect(container.children('.pane').length).toBe 1
expect(pane1.outerWidth()).toBe container.width()
describe "autosave", ->
[initialActiveItem, initialActiveItemUri] = []
beforeEach ->
initialActiveItem = pane.activeItem
initialActiveItemUri = null
pane.activeItem.getUri = -> initialActiveItemUri
pane.activeItem.save = jasmine.createSpy("activeItem.save")
spyOn(pane, 'saveItem').andCallThrough()
describe "when the active view loses focus", ->
it "saves the item if core.autosave is true and the item has a uri", ->
pane.activeView.trigger 'focusout'
expect(pane.saveItem).not.toHaveBeenCalled()
expect(pane.activeItem.save).not.toHaveBeenCalled()
config.set('core.autosave', true)
pane.activeView.trigger 'focusout'
expect(pane.saveItem).not.toHaveBeenCalled()
expect(pane.activeItem.save).not.toHaveBeenCalled()
initialActiveItemUri = path.join(temp.dir, 'hi')
pane.activeView.trigger 'focusout'
expect(pane.activeItem.save).toHaveBeenCalled()
describe "when an item becomes inactive", ->
it "saves the item if core.autosave is true and the item has a uri", ->
expect(view2).not.toBe pane.activeItem
expect(pane.saveItem).not.toHaveBeenCalled()
expect(initialActiveItem.save).not.toHaveBeenCalled()
pane.showItem(view2)
pane.showItem(initialActiveItem)
config.set('core.autosave', true)
pane.showItem(view2)
expect(pane.saveItem).not.toHaveBeenCalled()
expect(initialActiveItem.save).not.toHaveBeenCalled()
pane.showItem(initialActiveItem)
initialActiveItemUri = path.join(temp.dir, 'hi')
pane.showItem(view2)
expect(initialActiveItem.save).toHaveBeenCalled()
describe "when an item is destroyed", ->
it "saves the item if core.autosave is true and the item has a uri", ->
# doesn't have to be the active item
expect(view2).not.toBe pane.activeItem
pane.showItem(view2)
pane.destroyItem(editSession1)
expect(pane.saveItem).not.toHaveBeenCalled()
config.set("core.autosave", true)
view2.getUri = -> undefined
view2.save = ->
pane.destroyItem(view2)
expect(pane.saveItem).not.toHaveBeenCalled()
initialActiveItemUri = path.join(temp.dir, 'hi')
pane.destroyItem(initialActiveItem)
expect(initialActiveItem.save).toHaveBeenCalled()
describe ".itemForUri(uri)", ->
it "returns the item for which a call to .getUri() returns the given uri", ->
expect(pane.itemForUri(editSession1.getUri())).toBe editSession1

View File

@ -81,7 +81,6 @@ class Pane extends View
@command 'pane:close-other-items', => @destroyInactiveItems()
@on 'focus', => @activeView?.focus(); false
@on 'focusin', => @makeActive()
@on 'focusout', => @autosaveActiveItem()
# Private:
afterAttach: (onDom) ->
@ -159,7 +158,6 @@ class Pane extends View
if @activeItem
@activeItem.off? 'title-changed', @activeItemTitleChanged
@autosaveActiveItem()
isFocused = @is(':has(:focus)')
@addItem(item)
@ -203,8 +201,6 @@ class Pane extends View
container.itemDestroyed(item)
item.destroy?()
@autosaveItem(item)
if item.shouldPromptToSave?()
reallyDestroyItem() if @promptToSaveItem(item)
else
@ -264,15 +260,7 @@ class Pane extends View
saveItems: =>
@saveItem(item) for item in @getItems()
# Public: Autosaves the currently focused item.
autosaveActiveItem: ->
@autosaveItem(@activeItem)
# Public: Autosaves the given focused item if configured to do so.
autosaveItem: (item) ->
@saveItem(item) if config.get('core.autosave') and item.getUri?()
# Public: Autosaves the given focused item if configured to do so.
# Public:
removeItem: (item) ->
index = @items.indexOf(item)
@removeItemAtIndex(index) if index >= 0

View File

@ -44,7 +44,6 @@ class RootView extends View
@version: 1
@configDefaults:
autosave: false
ignoredNames: [".git", ".svn", ".DS_Store"]
excludeVcsIgnoredPaths: true
disabledPackages: []