From c39172d6253ae55307989ed04d021644c735d8b3 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Fri, 13 Jul 2012 09:04:22 -0700 Subject: [PATCH 1/4] Change fold colors for twilight theme --- static/theme/twilight.css | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/static/theme/twilight.css b/static/theme/twilight.css index ddd2d0e5e..a50119c5e 100644 --- a/static/theme/twilight.css +++ b/static/theme/twilight.css @@ -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; -}"; +} From d44c648d4b4b38b6b9ce02b546a216d802d16067 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Fri, 13 Jul 2012 09:05:38 -0700 Subject: [PATCH 2/4] Editor.renderedLines' width is set to the maximum of either Editor.scrollView's width or the maximum rendered line width --- spec/app/editor-spec.coffee | 11 +++++++---- src/app/editor.coffee | 6 +++++- static/editor.css | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index bce9373d3..445471590 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -1239,8 +1239,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 +1320,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", -> diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 7d7946fcd..2288251fd 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -650,7 +650,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() diff --git a/static/editor.css b/static/editor.css index c43298fcb..c4edec6e3 100644 --- a/static/editor.css +++ b/static/editor.css @@ -66,7 +66,6 @@ .editor .lines { position: relative; display: table; - width: 100%; height: 100%; } From 9dfa7d9439acda598a497aa3be78b50ccdf44ed7 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 13 Jul 2012 09:24:14 -0700 Subject: [PATCH 3/4] When splitting an editor only the active edit session is copied to the new editor. --- spec/app/editor-spec.coffee | 11 ++++++----- src/app/editor.coffee | 12 ++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 445471590..f88789f89 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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", -> diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2288251fd..c3fbe71d7 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -519,17 +519,21 @@ class Editor extends View @updateCursorViews() @updateRenderedLines() + newSplitEditor: -> + editSession = EditSession.deserialize(@activeEditSession.serialize(), this, @rootView()) + new Editor { editSession } + 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() From 23b42faa1dea9c42c6ed1a763a7ba3ee4c0f7c95 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 13 Jul 2012 09:35:19 -0700 Subject: [PATCH 4/4] Added EditSession.copy() Also, EditSession only needs a project to be deserialized --- src/app/edit-session.coffee | 7 +++++-- src/app/editor.coffee | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 53d4a265c..6f2ececfe 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -12,8 +12,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) @@ -65,6 +65,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 diff --git a/src/app/editor.coffee b/src/app/editor.coffee index c3fbe71d7..7fe8edba2 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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 @@ -520,8 +520,7 @@ class Editor extends View @updateRenderedLines() newSplitEditor: -> - editSession = EditSession.deserialize(@activeEditSession.serialize(), this, @rootView()) - new Editor { editSession } + new Editor { editSession: @activeEditSession.copy() } splitLeft: -> @pane()?.splitLeft(@newSplitEditor()).wrappedView