mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
When editor is split, set same cursor position on new editor and focus it.
This commit is contained in:
parent
8add398e9c
commit
2903126047
@ -1,6 +1,7 @@
|
|||||||
$ = require 'jquery'
|
$ = require 'jquery'
|
||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
RootView = require 'root-view'
|
RootView = require 'root-view'
|
||||||
|
Buffer = require 'buffer'
|
||||||
|
|
||||||
describe "RootView", ->
|
describe "RootView", ->
|
||||||
rootView = null
|
rootView = null
|
||||||
@ -34,12 +35,14 @@ describe "RootView", ->
|
|||||||
|
|
||||||
describe "split editor panes", ->
|
describe "split editor panes", ->
|
||||||
describe "when split-right is triggered on the editor", ->
|
describe "when split-right is triggered on the editor", ->
|
||||||
it "places the a new editor to the right of the current editor in a .horizontal div, and focuses the new editor", ->
|
fit "places the a new editor to the right of the current editor in a .horizontal div, and focuses the new editor", ->
|
||||||
rootView.attachToDom()
|
rootView.attachToDom()
|
||||||
|
|
||||||
expect(rootView.find('.horizontal')).not.toExist()
|
expect(rootView.find('.horizontal')).not.toExist()
|
||||||
|
|
||||||
editor1 = rootView.find('.editor').view()
|
editor1 = rootView.find('.editor').view()
|
||||||
|
editor1.setBuffer(new Buffer(require.resolve 'fixtures/sample.js'))
|
||||||
|
editor1.setCursorScreenPosition([3, 2])
|
||||||
editor1.trigger 'split-right'
|
editor1.trigger 'split-right'
|
||||||
|
|
||||||
expect(rootView.find('.horizontal')).toExist()
|
expect(rootView.find('.horizontal')).toExist()
|
||||||
@ -47,6 +50,12 @@ describe "RootView", ->
|
|||||||
expect(rootView.find('.horizontal .editor:eq(0)').view()).toBe editor1
|
expect(rootView.find('.horizontal .editor:eq(0)').view()).toBe editor1
|
||||||
editor2 = rootView.find('.horizontal .editor:eq(1)').view()
|
editor2 = rootView.find('.horizontal .editor:eq(1)').view()
|
||||||
expect(editor2.buffer).toBe editor1.buffer
|
expect(editor2.buffer).toBe editor1.buffer
|
||||||
|
expect(editor2.getCursorScreenPosition()).toEqual [3, 2]
|
||||||
|
expect(editor1).toHaveClass 'split'
|
||||||
|
expect(editor2).toHaveClass 'split'
|
||||||
|
|
||||||
|
expect(editor1.has(':focus')).not.toExist()
|
||||||
|
expect(editor2.has(':focus')).toExist()
|
||||||
|
|
||||||
# insertion reflected in both buffers
|
# insertion reflected in both buffers
|
||||||
editor1.buffer.insert([0, 0], 'ABC')
|
editor1.buffer.insert([0, 0], 'ABC')
|
||||||
|
@ -38,7 +38,7 @@ class Editor extends View
|
|||||||
autoIndent: null
|
autoIndent: null
|
||||||
lineCache: null
|
lineCache: null
|
||||||
|
|
||||||
initialize: () ->
|
initialize: ({buffer}) ->
|
||||||
requireStylesheet 'editor.css'
|
requireStylesheet 'editor.css'
|
||||||
requireStylesheet 'theme/twilight.css'
|
requireStylesheet 'theme/twilight.css'
|
||||||
@id = Editor.idCounter++
|
@id = Editor.idCounter++
|
||||||
@ -46,7 +46,7 @@ class Editor extends View
|
|||||||
@bindKeys()
|
@bindKeys()
|
||||||
@buildCursorAndSelection()
|
@buildCursorAndSelection()
|
||||||
@handleEvents()
|
@handleEvents()
|
||||||
@setBuffer(new Buffer)
|
@setBuffer(buffer ? new Buffer)
|
||||||
@autoIndent = true
|
@autoIndent = true
|
||||||
|
|
||||||
bindKeys: ->
|
bindKeys: ->
|
||||||
@ -404,8 +404,8 @@ class Editor extends View
|
|||||||
horizontal = $$ -> @div class: 'horizontal'
|
horizontal = $$ -> @div class: 'horizontal'
|
||||||
horizontal.insertBefore(this).append(this.detach())
|
horizontal.insertBefore(this).append(this.detach())
|
||||||
|
|
||||||
editor = new Editor
|
editor = new Editor({@buffer})
|
||||||
editor.setBuffer(@buffer)
|
editor.setCursorScreenPosition(@getCursorScreenPosition())
|
||||||
@after(editor)
|
@after(editor)
|
||||||
@addClass 'split'
|
@addClass 'split'
|
||||||
editor.addClass('split')
|
editor.addClass('split')
|
||||||
|
Loading…
Reference in New Issue
Block a user