From c67f8493e0783a6c73992e29f35fb39853638019 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Jul 2014 15:14:45 -0700 Subject: [PATCH 1/2] Softwrap always takes into account the vertical scrollbar width --- src/display-buffer.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 6c56ee106..9e6468e88 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -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 From 17364cd528fcdd3c402878867852bf243f8d6110 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Fri, 11 Jul 2014 15:12:41 -0700 Subject: [PATCH 2/2] Take the scrollbar width into account in specs --- spec/editor-component-spec.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 0104be6f5..3d8af165f 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -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 "