mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
"Scroll" gutter by relatively positioning its line numbers
This matches how we scroll lines, and eliminates opportunities for the gutter to get out of sync with the lines. If that happened, it would probably be a bug, but this at least eliminates one source of confusion when debugging.
This commit is contained in:
parent
e21d0a5d2a
commit
3ee7c0dc0f
@ -337,13 +337,13 @@ describe "Editor", ->
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 100
|
||||
expect(editor.scrollView.scrollTop()).toBe 0
|
||||
expect(editor.renderedLines.css('top')).toBe "-100px"
|
||||
expect(editor.gutter.scrollTop()).toBe 100
|
||||
expect(editor.gutter.lineNumbers.css('top')).toBe "-100px"
|
||||
|
||||
editor.scrollTop(120)
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 120
|
||||
expect(editor.scrollView.scrollTop()).toBe 0
|
||||
expect(editor.renderedLines.css('top')).toBe "-120px"
|
||||
expect(editor.gutter.scrollTop()).toBe 120
|
||||
expect(editor.gutter.lineNumbers.css('top')).toBe "-120px"
|
||||
|
||||
it "does not allow negative scrollTops to be assigned", ->
|
||||
editor.scrollTop(-100)
|
||||
@ -365,7 +365,7 @@ describe "Editor", ->
|
||||
editor.scrollTop(100, adjustVerticalScrollbar: false)
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 0
|
||||
expect(editor.renderedLines.css('top')).toBe "-100px"
|
||||
expect(editor.gutter.scrollTop()).toBe 100
|
||||
expect(editor.gutter.lineNumbers.css('top')).toBe "-100px"
|
||||
|
||||
describe "when called with no argument", ->
|
||||
it "returns the last assigned value or 0 if none has been assigned", ->
|
||||
|
@ -413,7 +413,7 @@ class Editor extends View
|
||||
@updateRenderedLines() if @attached
|
||||
|
||||
@renderedLines.css('top', -scrollTop)
|
||||
@gutter.scrollTop(scrollTop)
|
||||
@gutter.lineNumbers.css('top', -scrollTop)
|
||||
if options?.adjustVerticalScrollbar ? true
|
||||
@verticalScrollbar.scrollTop(scrollTop)
|
||||
|
||||
|
@ -7,7 +7,7 @@ module.exports =
|
||||
class Gutter extends View
|
||||
@content: ->
|
||||
@div class: 'gutter', =>
|
||||
@div outlet: 'lineNumbers', class: 'wtf'
|
||||
@div outlet: 'lineNumbers', class: 'line-numbers'
|
||||
|
||||
editor: ->
|
||||
editor = @parentView
|
||||
|
@ -27,6 +27,10 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.editor .gutter .line-numbers {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.editor.mini .gutter {
|
||||
display: none;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user