mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Rename Buffer.numLines to Buffer.getLineCount
This commit is contained in:
parent
32b3dfa0ca
commit
30d07fd1a0
@ -26,7 +26,7 @@ describe "Editor", ->
|
||||
buffer = editor.buffer
|
||||
|
||||
editor.attachToDom = ({ heightInLines } = {}) ->
|
||||
heightInLines ?= this.buffer.numLines()
|
||||
heightInLines ?= this.buffer.getLineCount()
|
||||
this.height(getLineHeight() * heightInLines)
|
||||
$('#jasmine-content').append(this)
|
||||
|
||||
@ -343,10 +343,10 @@ describe "Editor", ->
|
||||
describe "when all lines in the buffer are visible on screen", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom()
|
||||
expect(editor.height()).toBe buffer.numLines() * editor.lineHeight
|
||||
expect(editor.height()).toBe buffer.getLineCount() * editor.lineHeight
|
||||
|
||||
it "creates a line element for each line in the buffer with the html-escaped text of the line", ->
|
||||
expect(editor.visibleLines.find('.line').length).toEqual(buffer.numLines())
|
||||
expect(editor.visibleLines.find('.line').length).toEqual(buffer.getLineCount())
|
||||
expect(buffer.lineForRow(2)).toContain('<')
|
||||
expect(editor.visibleLines.find('.line:eq(2)').html()).toContain '<'
|
||||
|
||||
@ -469,7 +469,7 @@ describe "Editor", ->
|
||||
|
||||
it "only renders the visible lines plus the overdrawn lines, setting the padding-bottom of the lines element to account for the missing lines", ->
|
||||
expect(editor.visibleLines.find('.line').length).toBe 8
|
||||
expectedPaddingBottom = (buffer.numLines() - 8) * editor.lineHeight
|
||||
expectedPaddingBottom = (buffer.getLineCount() - 8) * editor.lineHeight
|
||||
expect(editor.visibleLines.css('padding-bottom')).toBe "#{expectedPaddingBottom}px"
|
||||
expect(editor.visibleLines.find('.line:first').text()).toBe buffer.lineForRow(0)
|
||||
expect(editor.visibleLines.find('.line:last').text()).toBe buffer.lineForRow(7)
|
||||
@ -592,12 +592,12 @@ describe "Editor", ->
|
||||
|
||||
lastVisibleBufferRow = Math.ceil(3 + 5.5) # scroll top in lines + height in lines
|
||||
lastOverdrawnRow = lastVisibleBufferRow + editor.lineOverdraw
|
||||
expectedPaddingBottom = ((buffer.numLines() - lastOverdrawnRow) * editor.lineHeight)
|
||||
expectedPaddingBottom = ((buffer.getLineCount() - lastOverdrawnRow) * editor.lineHeight)
|
||||
expect(editor.visibleLines.css('padding-bottom')).toBe "#{expectedPaddingBottom}px"
|
||||
|
||||
editor.scrollToBottom()
|
||||
# scrolled to bottom, first visible row is 5 and first rendered row is 3
|
||||
firstVisibleBufferRow = Math.floor(buffer.numLines() - 5.5)
|
||||
firstVisibleBufferRow = Math.floor(buffer.getLineCount() - 5.5)
|
||||
firstOverdrawnBufferRow = firstVisibleBufferRow - editor.lineOverdraw
|
||||
expectedPaddingTop = firstOverdrawnBufferRow * editor.lineHeight
|
||||
expect(editor.visibleLines.css('padding-top')).toBe "#{expectedPaddingTop}px"
|
||||
|
@ -9,7 +9,7 @@ class AceFoldAdaptor
|
||||
@buffer.lineForRow(bufferRow)
|
||||
|
||||
getLength: ->
|
||||
@buffer.numLines()
|
||||
@buffer.getLineCount()
|
||||
|
||||
$findClosingBracket: (bracketType, bufferPosition) ->
|
||||
@highlighter.findClosingBracket([bufferPosition.row, bufferPosition.column - 1])
|
||||
|
@ -76,7 +76,7 @@ class Buffer
|
||||
rangeForRow: (row) ->
|
||||
new Range([row, 0], [row, @lineLengthForRow(row)])
|
||||
|
||||
numLines: ->
|
||||
getLineCount: ->
|
||||
@getLines().length
|
||||
|
||||
getLastRow: ->
|
||||
|
@ -28,7 +28,7 @@ class MoveUp extends Motion
|
||||
class MoveDown extends Motion
|
||||
execute: ->
|
||||
{column, row} = @editor.getCursorScreenPosition()
|
||||
@editor.moveCursorDown() if row < (@editor.buffer.numLines() - 1)
|
||||
@editor.moveCursorDown() if row < (@editor.buffer.getLineCount() - 1)
|
||||
|
||||
class MoveToPreviousWord extends Motion
|
||||
execute: ->
|
||||
@ -55,7 +55,7 @@ class MoveToNextWord extends Motion
|
||||
|
||||
if match
|
||||
column += match.index
|
||||
else if row + 1 == @editor.buffer.numLines()
|
||||
else if row + 1 == @editor.buffer.getLineCount()
|
||||
column = @editor.buffer.lineForRow(row).length
|
||||
else
|
||||
nextLineMatch = regex.exec(@editor.buffer.lineForRow(++row))
|
||||
|
Loading…
Reference in New Issue
Block a user