Gutter adjusts its width to account for the width of the last line number

This commit is contained in:
Corey Johnson 2012-05-17 10:16:20 -07:00
parent 7a82bf2679
commit 0e09659d79
2 changed files with 12 additions and 1 deletions

View File

@ -558,6 +558,15 @@ describe "Editor", ->
expect(editor.gutter.find('.line-number:first').text()).toBe "2"
expect(editor.gutter.find('.line-number:last').text()).toBe "7"
describe "width", ->
it "sets the width based on last line number", ->
expect(editor.gutter.lineNumbers.outerWidth()).toBe editor.charWidth * 2
it "updates the width when total number of lines gains a digit", ->
oneHundredLines = [0..100].join("\n")
editor.insertText(oneHundredLines)
expect(editor.gutter.lineNumbers.outerWidth()).toBe editor.charWidth * 3
describe "when wrapping is on", ->
it "renders a • instead of line number for wrapped portions of lines", ->
editor.setMaxLineLength(50)

View File

@ -17,4 +17,6 @@ class Gutter extends View
@lineNumbers[0].innerHTML = $$$ ->
for row in rows
@div {class: 'line-number'}, if row == lastScreenRow then '' else row + 1
lastScreenRow = row
lastScreenRow = row
@lineNumbers.width(editor.getLastScreenRow().toString().length * editor.charWidth)