atom/atom — pull request #2919 by benogle (2014-07-10 22:49:28+00:00)
Title: Fix width too wide when softwrap enabled when editor can vertical scroll

1. Enable softwrap on a longish md file.
2. Scroll to the right
3. Editor twerk

![softwrap-wiggle](https://cloud.githubusercontent.com/assets/69169/3546128/d15e581e-087f-11e4-9356-9620c83851b7.gif)

`DisplayBuffer::getEditorWidthInChars()` is not taking into account the width of the scrollbar when the editor can vertical scroll.

This fix takes the scrollbar width into account all the time, even when it cannot scroll vertically.

It might be cool to only take the scrollbar into account when there it can vertical scroll, and the scrollbar is visible. But there are a couple problems with it:

* UX: when it switches from able to scroll to not able to scroll, it would reset the column, and reflow some lines.
* It's a chicken and egg problem. Basically, to figure out if we need the scrollbar, we need to know all the screenlines, and to build the screenlines we need to know the softwrap column. But to figure out the softwrap column, we need to know if we show the scrollbar.

Here's what happens on resize of the editor in softwrap:

![screen shot 2014-07-10 at 3 29 37 pm](https://cloud.githubusercontent.com/assets/69169/3546309/b89fa66e-0881-11e4-93c7-310c8c499314.png)

`UpdateAllScreenLines` [deletes all the old screen lines](https://github.com/atom/atom/blob/master/src/display-buffer.coffee#L94) then [figures out the softwrap column](https://github.com/atom/atom/blob/master/src/display-buffer.coffee#L366), so it cannot know whether or not there should be a vert scrollbar.

Here are the ways I can think to get the proper column:

* We keep the old screenlines around, and determine scrollability based on those. Though there might be cases where it does the wrong thing because the screen lines changed drastically (say a huge resize).
* We compute the screen lines twice. Once with the scrollbar, if it isnt scrollable, then compute again without the scrollbar.
* Just account for the scrollbar all the time (as this pull does)

I'd prefer to merge this pull. Curious about your thoughts