mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Opening a previously opened url restores the same buffer and session.
This commit is contained in:
@@ -14,6 +14,7 @@ class Editor extends Template
|
||||
buffer: null
|
||||
|
||||
initialize: () ->
|
||||
@aceSessions = {}
|
||||
@buildAceEditor()
|
||||
@setBuffer(new Buffer)
|
||||
|
||||
@@ -24,8 +25,10 @@ class Editor extends Template
|
||||
@aceEditor.destroy()
|
||||
|
||||
setBuffer: (@buffer) ->
|
||||
session = new EditSession(@buffer.aceDocument, @buffer.getMode())
|
||||
@aceEditor.setSession(session)
|
||||
@aceEditor.setSession @getAceSessionForBuffer(buffer)
|
||||
|
||||
getAceSessionForBuffer: (buffer) ->
|
||||
@aceSessions[@buffer.url] ?= new EditSession(@buffer.aceDocument, @buffer.getMode())
|
||||
|
||||
buildAceEditor: ->
|
||||
@aceEditor = ace.edit this[0]
|
||||
|
||||
@@ -4,17 +4,19 @@ Buffer = require 'buffer'
|
||||
module.exports =
|
||||
|
||||
class Project
|
||||
buffers: null
|
||||
|
||||
constructor: (@url) ->
|
||||
@buffers = {}
|
||||
|
||||
getFilePaths: ->
|
||||
fs.async.listFiles(@url, true)
|
||||
|
||||
open: (filePath) ->
|
||||
new Buffer(@resolve(filePath))
|
||||
filePath = @resolve filePath
|
||||
@buffers[filePath] ?= new Buffer(filePath)
|
||||
|
||||
resolve: (filePath) ->
|
||||
if filePath[0] == '/'
|
||||
filePath
|
||||
else
|
||||
fs.join(@url, filePath)
|
||||
filePath = fs.join(@url, filePath) unless filePath[0] == '/'
|
||||
fs.absolute filePath
|
||||
|
||||
|
||||
Reference in New Issue
Block a user