mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Tag selection markers with a disambiguating EditSession id
This prevents selection markers created by different edit sessions from being shared. Otherwise every edit session for a buffer would be forced to have the same selection/cursor state.
This commit is contained in:
parent
ab8c0bbf04
commit
a724ef3b40
@ -946,6 +946,12 @@ describe "EditSession", ->
|
||||
editSession.setCursorScreenPosition([3, 3])
|
||||
expect(selection.isEmpty()).toBeTruthy()
|
||||
|
||||
it "does not share selections between different edit sessions for the same buffer", ->
|
||||
editSession2 = project.open('sample.js')
|
||||
editSession.setSelectedBufferRanges([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
|
||||
editSession2.setSelectedBufferRanges([[[8, 7], [6, 5]], [[4, 3], [2, 1]]])
|
||||
expect(editSession2.getSelectedBufferRanges()).not.toEqual editSession.getSelectedBufferRanges()
|
||||
|
||||
describe "buffer manipulation", ->
|
||||
describe ".insertText(text)", ->
|
||||
describe "when there are multiple empty selections", ->
|
||||
|
@ -2,6 +2,7 @@ _ = require 'underscore'
|
||||
fsUtils = require 'fs-utils'
|
||||
path = require 'path'
|
||||
telepath = require 'telepath'
|
||||
guid = require 'guid'
|
||||
{Point, Range} = telepath
|
||||
Buffer = require 'text-buffer'
|
||||
LanguageMode = require 'language-mode'
|
||||
@ -26,6 +27,7 @@ class EditSession
|
||||
@deserialize: (state) ->
|
||||
new EditSession(state)
|
||||
|
||||
id: null
|
||||
languageMode: null
|
||||
displayBuffer: null
|
||||
cursors: null
|
||||
@ -40,7 +42,7 @@ class EditSession
|
||||
if optionsOrState instanceof telepath.Document
|
||||
project.editSessions.push(this)
|
||||
@state = optionsOrState
|
||||
{tabLength, softTabs, @softWrap} = @state.toObject()
|
||||
{@id, tabLength, softTabs, @softWrap} = @state.toObject()
|
||||
@setBuffer(project.bufferForId(@state.get('bufferId')))
|
||||
@buildDisplayBuffer({tabLength})
|
||||
@addSelection(marker) for marker in @findMarkers(@getSelectionMarkerAttributes())
|
||||
@ -48,9 +50,11 @@ class EditSession
|
||||
@setScrollLeft(@state.get('scrollLeft'))
|
||||
else
|
||||
{buffer, tabLength, softTabs, @softWrap} = optionsOrState
|
||||
@id = guid.create().toString()
|
||||
@state = telepath.Document.create
|
||||
deserializer: 'EditSession'
|
||||
version: @constructor.version
|
||||
id: @id
|
||||
scrollTop: 0
|
||||
scrollLeft: 0
|
||||
@setBuffer(buffer)
|
||||
|
Loading…
Reference in New Issue
Block a user