mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
EditSession informs cursor models of buffer changes (instead of Editor informing cursor views)
This commit is contained in:
@@ -26,10 +26,6 @@ class CursorView extends View
|
||||
@updateAppearance()
|
||||
@editor.syncCursorAnimations()
|
||||
|
||||
handleBufferChange: (e) ->
|
||||
@cursor.handleBufferChange(e)
|
||||
@trigger 'cursor-move', bufferChange: true
|
||||
|
||||
remove: ->
|
||||
@editor.compositeCursor.removeCursor(this)
|
||||
@editor.compositeSelection.removeSelectionForCursor(this)
|
||||
|
||||
@@ -7,6 +7,8 @@ _ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class EditSession
|
||||
@idCounter: 1
|
||||
|
||||
@deserialize: (state, editor, rootView) ->
|
||||
buffer = Buffer.deserialize(state.buffer, rootView.project)
|
||||
session = new EditSession(editor, buffer)
|
||||
@@ -21,12 +23,17 @@ class EditSession
|
||||
cursors: null
|
||||
|
||||
constructor: (@editor, @buffer) ->
|
||||
@id = @constructor.idCounter++
|
||||
@renderer = new Renderer(@buffer, { softWrapColumn: @editor.calcSoftWrapColumn(), tabText: @editor.tabText })
|
||||
@cursors = []
|
||||
@addCursorAtScreenPosition([0, 0])
|
||||
|
||||
@buffer.on "change.edit-session-#{@id}", (e) =>
|
||||
@moveCursors (cursor) -> cursor.handleBufferChange(e)
|
||||
|
||||
destroy: ->
|
||||
@renderer.destroy()
|
||||
@buffer.off ".edit-session-#{@id}"
|
||||
|
||||
serialize: ->
|
||||
buffer: @buffer.serialize()
|
||||
|
||||
@@ -452,7 +452,6 @@ class Editor extends View
|
||||
Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1
|
||||
|
||||
handleBufferChange: (e) ->
|
||||
@compositeCursor.handleBufferChange(e)
|
||||
@compositeSelection.handleBufferChange(e)
|
||||
|
||||
handleRendererChange: (e) ->
|
||||
|
||||
Reference in New Issue
Block a user