From 2465372bd4de91649b8eb12714818bddd9547ed7 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 3 Apr 2012 16:34:01 -0700 Subject: [PATCH] Multi-cursor scrolling is based on the last created cursor --- spec/app/editor-spec.coffee | 4 ++-- src/app/cursor.coffee | 2 +- src/app/editor.coffee | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index ffbebd862..c3496b671 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -677,8 +677,8 @@ describe "Editor", -> setEditorWidthInChars(editor, 20) setEditorHeightInChars(editor, 10) editor.setCursorBufferPosition([11,0]) - editor.addCursorAtBufferPosition([0,0]) editor.addCursorAtBufferPosition([6,50]) + editor.addCursorAtBufferPosition([0,0]) window.advanceClock() scrollHandler = spyOn(editor, 'scrollVertically') @@ -701,7 +701,7 @@ describe "Editor", -> editor.moveCursorRight() window.advanceClock() - position = editor.pixelPositionForScreenPosition([0,1]) + position = editor.pixelPositionForScreenPosition([6,1]) expect(scrollHandler).toHaveBeenCalledWith(position) describe "auto indent/outdent", -> diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index df0353841..6f61da400 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -136,5 +136,5 @@ class Cursor extends View position = @editor.pixelPositionForScreenPosition(screenPosition) @css(position) - if @editor.getCursors().length == 1 or @editor.screenPositionInBounds(screenPosition) + if this == _.last(@editor.getCursors()) @editor.scrollTo(position) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 045209419..61360caa0 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -37,7 +37,6 @@ class Editor extends View autoIndent: null lineCache: null isFocused: false - isScrolling: false initialize: ({buffer}) -> requireStylesheet 'editor.css' @@ -481,10 +480,7 @@ class Editor extends View @buffer.getMode() scrollTo: (position) -> - return if @isScrolling - @isScrolling = true _.defer => - @isScrolling = false @scrollVertically(position) @scrollHorizontally(position)