Skip to content

Commit

Permalink
Clicking jumps to scroll location on editor scroll bars
Browse files Browse the repository at this point in the history
  • Loading branch information
refactoringdr committed Aug 21, 2024
1 parent ba7ff02 commit db2f449
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Brick/BrEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ BrEditor >> beReadOnlyWithoutSelection [

{ #category : #accessing }
BrEditor >> computeVerticalScrollExtent [
^ self lastVisibleSegment textEnd - self firstVisibleSegment textStart
^ self lastVisibleSegment index - self firstVisibleSegment index
]

{ #category : #accessing }
BrEditor >> computeVerticalScrollOffset [
^ self firstVisibleSegment textStart
^ self firstVisibleSegment index
]

{ #category : #accessing }
BrEditor >> computeVerticalScrollRange [
^ self text size
^ self text lineCount
]

{ #category : #'editor - accessing' }
Expand Down Expand Up @@ -165,12 +165,10 @@ BrEditor >> navigator [

{ #category : #'api - scrolling' }
BrEditor >> onScrollBy: aWish [
| position linesOnScreen |
| position current |
position := aWish delta y asInteger.
linesOnScreen := self lastVisibleSegment index - self firstVisibleSegment index.
position > self computeVerticalScrollExtent
ifTrue: [ self scrollToPosition: self lastVisibleSegment index + linesOnScreen ]
ifFalse: [ self scrollToPosition: self firstVisibleSegment index - linesOnScreen ]
current := self firstVisibleSegment index.
self scrollToPosition: position + current
]

{ #category : #'editor - operations' }
Expand Down

0 comments on commit db2f449

Please sign in to comment.