mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Projects w/ EditSessions for now-deleted files can now be reloaded w/out error
This commit is contained in:
parent
68effe3303
commit
7937380eed
@ -74,6 +74,14 @@ describe "Editor", ->
|
||||
expect(newEditor.scrollTop()).toBe editor.scrollTop()
|
||||
expect(newEditor.scrollView.scrollLeft()).toBe 44
|
||||
|
||||
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(rootView.project.buildEditSessionForPath('/tmp/delete-me'))
|
||||
fs.remove('/tmp/delete-me')
|
||||
newEditor = editor.copy()
|
||||
expect(console.warn).toHaveBeenCalled()
|
||||
|
||||
describe "when the editor is attached to the dom", ->
|
||||
it "calculates line height and char width and updates the pixel position of the cursor", ->
|
||||
expect(editor.lineHeight).toBeNull()
|
||||
|
@ -9,13 +9,18 @@ EventEmitter = require 'event-emitter'
|
||||
Range = require 'range'
|
||||
AnchorRange = require 'anchor-range'
|
||||
_ = require 'underscore'
|
||||
fs = require 'fs'
|
||||
|
||||
module.exports =
|
||||
class EditSession
|
||||
@idCounter: 1
|
||||
|
||||
@deserialize: (state, project) ->
|
||||
session = project.buildEditSessionForPath(state.buffer)
|
||||
if fs.exists(state.buffer)
|
||||
session = project.buildEditSessionForPath(state.buffer)
|
||||
else
|
||||
console.warn "Could not build edit session for path '#{state.buffer}' because that file no longer exists"
|
||||
session = project.buildEditSessionForPath(null)
|
||||
session.setScrollTop(state.scrollTop)
|
||||
session.setScrollLeft(state.scrollLeft)
|
||||
session.setCursorScreenPosition(state.cursorScreenPosition)
|
||||
|
@ -119,8 +119,11 @@ class Project
|
||||
bufferForPath: (filePath) ->
|
||||
if filePath?
|
||||
filePath = @resolve(filePath)
|
||||
buffer = _.find @buffers, (buffer) -> buffer.getPath() == filePath
|
||||
buffer or @buildBuffer(filePath)
|
||||
if filePath
|
||||
buffer = _.find @buffers, (buffer) -> buffer.getPath() == filePath
|
||||
buffer or @buildBuffer(filePath)
|
||||
else
|
||||
|
||||
else
|
||||
@buildBuffer()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user