Support opening non-existent files from the CLI

This required changing text-buffer to support having a
path but not underlying file that exists yet.

Now calling RootView.open() with a non-existed path will
open a dirty empty editor to the path and the file will be
created on first save.
This commit is contained in:
Kevin Sawicki
2013-04-04 17:08:05 -07:00
parent 931ae677c1
commit 84107317bb
3 changed files with 40 additions and 11 deletions

View File

@@ -213,7 +213,7 @@ _.extend atom,
@pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?(data...)
when 'openPath'
path = data[0]
rootView?.open(path) if fsUtils.isFile(path)
rootView?.open(path)
setWindowState: (keyPath, value) ->
windowState = @getWindowState()

View File

@@ -37,13 +37,14 @@ class Buffer
@lineEndings = []
if path
throw "Path '#{path}' does not exist" unless fsUtils.exists(path)
@setPath(path)
if initialText?
@setText(initialText)
@updateCachedDiskContents()
else
else if fsUtils.exists(path)
@reload()
else
@setText('')
else
@setText(initialText ? '')