mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 16:08:24 +03:00
Don't autoscroll to bottom of buffer on selectAll
This commit is contained in:
parent
d1d3b45474
commit
19c8a39fc8
@ -876,6 +876,16 @@ describe "Editor", ->
|
||||
expect(editor.getSelectionViews().length).toBe 1
|
||||
expect(editor.find('.selection').length).toBe 3
|
||||
|
||||
describe "when the selection is created with the selectAll event", ->
|
||||
it "does not scroll to the end of the buffer", ->
|
||||
editor.height(150)
|
||||
editor.selectAll()
|
||||
expect(editor.scrollTop()).toBe 0
|
||||
|
||||
# does auto-scroll when the selection is cleared
|
||||
editor.moveCursorDown()
|
||||
expect(editor.scrollTop()).toBeGreaterThan(0)
|
||||
|
||||
describe "cursor rendering", ->
|
||||
describe "when the cursor moves", ->
|
||||
charWidth = null
|
||||
|
@ -66,12 +66,12 @@ class Anchor
|
||||
Object.freeze @bufferPosition
|
||||
|
||||
unless @screenPosition.isEqual(previousScreenPosition)
|
||||
@trigger 'change-screen-position', @screenPosition, bufferChange: options.bufferChange
|
||||
@trigger 'change-screen-position', @screenPosition, bufferChange: options.bufferChange, autoscroll: options.autoscroll
|
||||
|
||||
refreshScreenPosition: (options={}) ->
|
||||
return unless @editSession
|
||||
screenPosition = @editSession.screenPositionForBufferPosition(@bufferPosition, options)
|
||||
@setScreenPosition(screenPosition, bufferChange: options.bufferChange, clip: false, assignBufferPosition: false)
|
||||
@setScreenPosition(screenPosition, bufferChange: options.bufferChange, clip: false, assignBufferPosition: false, autoscroll: options.autoscroll)
|
||||
|
||||
destroy: ->
|
||||
@buffer.removeAnchor(this)
|
||||
|
@ -13,8 +13,8 @@ class CursorView extends View
|
||||
visible: true
|
||||
|
||||
initialize: (@cursor, @editor) ->
|
||||
@cursor.on 'change-screen-position.cursor-view', (screenPosition, { bufferChange }) =>
|
||||
@updateAppearance()
|
||||
@cursor.on 'change-screen-position.cursor-view', (screenPosition, { bufferChange, autoscroll }) =>
|
||||
@updateAppearance({autoscroll})
|
||||
@removeIdleClassTemporarily() unless bufferChange
|
||||
@trigger 'cursor-move', {bufferChange}
|
||||
|
||||
@ -31,23 +31,30 @@ class CursorView extends View
|
||||
@cursor.off('.cursor-view')
|
||||
super
|
||||
|
||||
updateAppearance: ->
|
||||
updateAppearance: (options={}) ->
|
||||
screenPosition = @getScreenPosition()
|
||||
pixelPosition = @editor.pixelPositionForScreenPosition(screenPosition)
|
||||
pixelPosition = @getPixelPosition()
|
||||
@css(pixelPosition)
|
||||
|
||||
if @cursor == @editor.getLastCursor()
|
||||
@editor.scrollTo(pixelPosition)
|
||||
@autoscroll() if options.autoscroll ? true
|
||||
@editor.hiddenInput.css(pixelPosition)
|
||||
|
||||
@setVisible(@cursor.isVisible() and not @editor.isFoldedAtScreenRow(screenPosition.row))
|
||||
|
||||
getPixelPosition: ->
|
||||
@editor.pixelPositionForScreenPosition(@getScreenPosition())
|
||||
|
||||
autoscroll: ->
|
||||
@editor.scrollTo(@getPixelPosition())
|
||||
|
||||
setVisible: (visible) ->
|
||||
return if visible == @visible
|
||||
@visible = visible
|
||||
|
||||
if @visible
|
||||
@show()
|
||||
@autoscroll()
|
||||
else
|
||||
@hide()
|
||||
|
||||
|
@ -154,7 +154,7 @@ class Selection
|
||||
@modifySelection => @cursor.moveToBottom()
|
||||
|
||||
selectAll: ->
|
||||
@setBufferRange(@editSession.buffer.getRange())
|
||||
@setBufferRange(@editSession.buffer.getRange(), autoscroll: false)
|
||||
|
||||
selectToBeginningOfLine: ->
|
||||
@modifySelection => @cursor.moveToBeginningOfLine()
|
||||
|
Loading…
Reference in New Issue
Block a user