Merge pull request #2919 from atom/bo-the-wiggle

Fix width too wide when softwrap enabled when editor can vertical scroll
This commit is contained in:
Ben Ogle
2014-07-22 12:42:49 -07:00
2 changed files with 5 additions and 3 deletions

View File

@@ -258,7 +258,7 @@ describe "EditorComponent", ->
editor.setText "a line that wraps "
editor.setSoftWrap(true)
runSetImmediateCallbacks()
componentNode.style.width = 16 * charWidth + 'px'
componentNode.style.width = 16 * charWidth + editor.getVerticalScrollbarWidth() + 'px'
component.measureHeightAndWidth()
runSetImmediateCallbacks()
@@ -2003,7 +2003,7 @@ describe "EditorComponent", ->
expect(componentNode.querySelectorAll('.line')).toHaveLength(4 + lineOverdrawMargin + 1)
gutterWidth = componentNode.querySelector('.gutter').offsetWidth
componentNode.style.width = gutterWidth + 14 * charWidth + 'px'
componentNode.style.width = gutterWidth + 14 * charWidth + editor.getVerticalScrollbarWidth() + 'px'
advanceClock(component.domPollingInterval)
runSetImmediateCallbacks()
expect(componentNode.querySelector('.line').textContent).toBe "var quicksort "

View File

@@ -356,8 +356,10 @@ class DisplayBuffer extends Model
if editorWidthInChars isnt previousWidthInChars and @softWrap
@updateWrappedScreenLines()
# Returns the editor width in characters for soft wrap.
getEditorWidthInChars: ->
width = @getWidth()
width = @width ? @getScrollWidth()
width -= @getVerticalScrollbarWidth()
if width? and @defaultCharWidth > 0
Math.floor(width / @defaultCharWidth)
else