Merge branch 'master' into global-find

This commit is contained in:
Corey Johnson
2012-07-13 09:36:21 -07:00
5 changed files with 36 additions and 24 deletions

View File

@@ -356,13 +356,14 @@ describe "Editor", ->
fakePane = { splitUp: jasmine.createSpy('splitUp').andReturn({}), remove: -> }
spyOn(editor, 'pane').andReturn(fakePane)
it "calls the corresponding split method on the containing pane with a copy of the editor", ->
it "calls the corresponding split method on the containing pane with a new editor containing a copy of the active edit session", ->
editor.edit project.open("sample.txt")
editor.splitUp()
expect(fakePane.splitUp).toHaveBeenCalled()
[editorCopy] = fakePane.splitUp.argsForCall[0]
expect(editorCopy.serialize()).toEqual editor.serialize()
expect(editorCopy).not.toBe editor
editorCopy.remove()
[newEditor] = fakePane.splitUp.argsForCall[0]
expect(newEditor.editSessions.length).toEqual 1
expect(newEditor.activeEditSession.buffer).toBe editor.activeEditSession.buffer
newEditor.remove()
describe "when not inside a pane", ->
it "does not split the editor, but doesn't throw an exception", ->
@@ -1239,8 +1240,9 @@ describe "Editor", ->
expect(editor.renderedLines.find(".line:first").text()).toBe buffer.lineForRow(0)
expect(editor.renderedLines.find(".line:last").text()).toBe buffer.lineForRow(6)
it "increases the width of the rendered lines element if the max line length changes", ->
it "increases the width of the rendered lines element to be either the width of the longest line or the width of the scrollView (whichever is longer)", ->
widthBefore = editor.renderedLines.width()
expect(widthBefore).toBe editor.scrollView.width()
buffer.change([[12,0], [12,0]], [1..50].join(''))
expect(editor.renderedLines.width()).toBeGreaterThan widthBefore
@@ -1319,10 +1321,12 @@ describe "Editor", ->
expect(editor.find('.line').length).toBe 7
it "decreases the width of the rendered screen lines if the max line length changes", ->
it "sets the rendered screen line's width to either the max line length or the scollView's width (whichever is greater)", ->
buffer.change([[12,0], [12,0]], [1..100].join(''))
expect(editor.renderedLines.width()).toBeGreaterThan editor.scrollView.width()
widthBefore = editor.renderedLines.width()
buffer.delete([[6, 0], [6, Infinity]])
expect(editor.renderedLines.width()).toBeLessThan widthBefore
buffer.delete([[12, 0], [12, Infinity]])
expect(editor.renderedLines.width()).toBe editor.scrollView.width()
describe "when folding leaves less then a screen worth of text (regression)", ->
it "renders lines properly", ->

View File

@@ -13,8 +13,8 @@ module.exports =
class EditSession
@idCounter: 1
@deserialize: (state, editor, rootView) ->
session = rootView.project.open(state.buffer)
@deserialize: (state, project) ->
session = project.open(state.buffer)
session.setScrollTop(state.scrollTop)
session.setScrollLeft(state.scrollLeft)
session.setCursorScreenPosition(state.cursorScreenPosition)
@@ -66,6 +66,9 @@ class EditSession
scrollLeft: @getScrollLeft()
cursorScreenPosition: @getCursorScreenPosition().serialize()
copy: ->
EditSession.deserialize(@serialize(), @project)
isEqual: (other) ->
return false unless other instanceof EditSession
@buffer == other.buffer and

View File

@@ -46,7 +46,7 @@ class Editor extends View
lineOverdraw: 100
@deserialize: (state, rootView) ->
editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, editor, rootView)
editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, rootView.project)
editor = new Editor(editSession: editSessions[state.activeEditSessionIndex], mini: state.mini)
editor.editSessions = editSessions
editor.isFocused = state.isFocused
@@ -519,17 +519,20 @@ class Editor extends View
@updateCursorViews()
@updateRenderedLines()
newSplitEditor: ->
new Editor { editSession: @activeEditSession.copy() }
splitLeft: ->
@pane()?.splitLeft(@copy()).wrappedView
@pane()?.splitLeft(@newSplitEditor()).wrappedView
splitRight: ->
@pane()?.splitRight(@copy()).wrappedView
@pane()?.splitRight(@newSplitEditor()).wrappedView
splitUp: ->
@pane()?.splitUp(@copy()).wrappedView
@pane()?.splitUp(@newSplitEditor()).wrappedView
splitDown: ->
@pane()?.splitDown(@copy()).wrappedView
@pane()?.splitDown(@newSplitEditor()).wrappedView
pane: ->
@parent('.pane').view()
@@ -650,7 +653,11 @@ class Editor extends View
@renderedLines.css('padding-bottom', heightOfRenderedLines)
adjustWidthOfRenderedLines: ->
@renderedLines.width(@charWidth * @maxScreenLineLength())
width = @charWidth * @maxScreenLineLength()
if width > @scrollView.width()
@renderedLines.width(width)
else
@renderedLines.width(@scrollView.width())
handleScrollHeightChange: ->
scrollHeight = @lineHeight * @screenLineCount()

View File

@@ -66,7 +66,6 @@
.editor .lines {
position: relative;
display: table;
width: 100%;
height: 100%;
}

View File

@@ -61,8 +61,8 @@ background-color:rgba(86, 45, 86, 0.75);
.invalid.deprecated {
text-decoration:underline;
font-style:italic;
color:#D2A8A1;
font-style:italic;
color:#D2A8A1;
}
.support {
@@ -70,12 +70,11 @@ color:#D2A8A1;
}
.fold {
background-color: #524228;
color: #969696;
background-color: #333;
}
.fold.selected {
background-color: #2A3B2A;
background-color: #1C2917;
color: #969696;
}
@@ -122,5 +121,5 @@ color:#5F5A60;
.markup.list {
color:#F9EE98;
}";
}