mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 18:24:09 +03:00
parent
ef6e525674
commit
8f030cd97e
@ -552,6 +552,7 @@ describe "Editor", ->
|
||||
describe "font size", ->
|
||||
beforeEach ->
|
||||
expect(editor.css('font-size')).not.toBe "20px"
|
||||
expect(editor.css('font-size')).not.toBe "10px"
|
||||
|
||||
it "sets the initial font size based on the value from config", ->
|
||||
expect($("head style.font-size")).toExist()
|
||||
@ -614,6 +615,23 @@ describe "Editor", ->
|
||||
config.set("editor.fontSize", 10)
|
||||
expect(editor.renderedLines.find(".line").length).toBeGreaterThan originalLineCount
|
||||
|
||||
describe "when the editor is detached", ->
|
||||
it "updates the font-size correctly and recalculates the dimensions by placing the rendered lines on the DOM", ->
|
||||
rootView.attachToDom()
|
||||
rootView.height(200)
|
||||
rootView.width(200)
|
||||
|
||||
newEditor = editor.splitRight()
|
||||
newEditorParent = newEditor.parent()
|
||||
newEditor.detach()
|
||||
config.set("editor.fontSize", 10)
|
||||
newEditorParent.append(newEditor)
|
||||
|
||||
expect(newEditor.lineHeight).toBe editor.lineHeight
|
||||
expect(newEditor.charWidth).toBe editor.charWidth
|
||||
expect(newEditor.getCursorView().position()).toEqual editor.getCursorView().position()
|
||||
expect(newEditor.verticalScrollbarContent.height()).toBe editor.verticalScrollbarContent.height()
|
||||
|
||||
describe "mouse events", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom()
|
||||
|
@ -804,6 +804,10 @@ class Editor extends View
|
||||
@overlayer.append(view)
|
||||
|
||||
calculateDimensions: ->
|
||||
if not @isOnDom()
|
||||
detachedEditorParent = _.last(@parents()) ? this
|
||||
$(document.body).append(detachedEditorParent)
|
||||
|
||||
fragment = $('<pre class="line" style="position: absolute; visibility: hidden;"><span>x</span></div>')
|
||||
@renderedLines.append(fragment)
|
||||
|
||||
@ -815,6 +819,8 @@ class Editor extends View
|
||||
@height(@lineHeight) if @mini
|
||||
fragment.remove()
|
||||
|
||||
$(detachedEditorParent).detach()
|
||||
|
||||
updateLayerDimensions: ->
|
||||
@gutter.calculateWidth()
|
||||
|
||||
|
@ -25,6 +25,9 @@ $.fn.pageUp = ->
|
||||
$.fn.pageDown = ->
|
||||
@scrollTop(@scrollTop() + @height())
|
||||
|
||||
$.fn.isOnDom = ->
|
||||
@closest(document.body).length is 1
|
||||
|
||||
$.fn.containsElement = (element) ->
|
||||
(element[0].compareDocumentPosition(this[0]) & 8) == 8
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user