Skip to content

Commit

Permalink
Merge branch 'master' into cj-add-react-editor-shims
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Sobo committed Jun 11, 2014
2 parents 131aad2 + 5add0e4 commit b73d267
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions spec/editor-component-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ describe "EditorComponent", ->
else
[node]

describe "when the buffer contains null bytes", ->
it "excludes the null byte from character measurement", ->
editor.setText("a\0b")
expect(editor.pixelPositionForScreenPosition([0, Infinity]).left).toEqual 2 * charWidth

describe "gutter rendering", ->
[lineNumberHasClass, gutter] = []

Expand Down
2 changes: 1 addition & 1 deletion src/display-buffer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ class DisplayBuffer extends Model
charWidths = @getScopedCharWidths(token.scopes)
for char in token.value
return {top, left} if column is targetColumn
left += charWidths[char] ? defaultCharWidth
left += charWidths[char] ? defaultCharWidth unless char is '\0'
column++
{top, left}

Expand Down
2 changes: 1 addition & 1 deletion src/editor-component.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ EditorComponent = React.createClass

onDecorationChanged: ->
@decorationChangedImmediate ?= setImmediate =>
@requestUpdate()
@requestUpdate() if @isMounted()
@decorationChangedImmediate = null

selectToMousePositionUntilMouseUp: (event) ->
Expand Down
2 changes: 2 additions & 0 deletions src/lines-component.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ LinesComponent = React.createClass
charWidths = editor.getScopedCharWidths(scopes)

for char in value
continue if char is '\0'

unless charWidths[char]?
unless textNode?
rangeForMeasurement ?= document.createRange()
Expand Down

0 comments on commit b73d267

Please sign in to comment.