Update editor width is chars when soft wrap is toggled

Closes #858
This commit is contained in:
Kevin Sawicki
2013-09-20 17:04:21 -07:00
parent de341a7f4c
commit 5a9972b370
2 changed files with 3 additions and 0 deletions

View File

@@ -1039,10 +1039,12 @@ describe "Editor", ->
describe "when the text exceeds the editor width and the scroll-view is horizontally scrolled", ->
it "wraps the text and renders properly", ->
editor.attachToDom(heightInLines: 30, widthInChars: 30)
editor.setWidthInChars(100)
editor.setText("Fashion axe umami jean shorts retro hashtag carles mumblecore. Photo booth skateboard Austin gentrify occupy ethical. Food truck gastropub keffiyeh, squid deep v pinterest literally sustainable salvia scenester messenger bag. Neutra messenger bag flexitarian four loko, shoreditch VHS pop-up tumblr seitan synth master cleanse. Marfa selvage ugh, raw denim authentic try-hard mcsweeney's trust fund fashion axe actually polaroid viral sriracha. Banh mi marfa plaid single-origin coffee. Pickled mumblecore lomo ugh bespoke.")
editor.scrollLeft(editor.charWidth * 30)
editor.trigger "editor:toggle-soft-wrap"
expect(editor.scrollLeft()).toBe 0
expect(editor.activeEditSession.getSoftWrapColumn()).not.toBe 100
describe "text rendering", ->
describe "when all lines in the buffer are visible on screen", ->

View File

@@ -929,6 +929,7 @@ class Editor extends View
# Toggle soft wrap on the edit session.
toggleSoftWrap: ->
@setWidthInChars()
@activeEditSession.setSoftWrap(not @activeEditSession.getSoftWrap())
calculateWidthInChars: ->