Skip to content

Commit

Permalink
🎨 Conflate setting default and double-width chars width
Browse files Browse the repository at this point in the history
Because they will always change together, and having two different setters seems
highly error-prone.
  • Loading branch information
as-cii committed Oct 15, 2015
1 parent 20b0523 commit 27dc3da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion spec/display-buffer-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe "DisplayBuffer", ->
describe "rendering of soft-wrapped lines", ->
describe "when there are double width characters", ->
it "takes them into account when finding the soft wrap column", ->
displayBuffer.setDoubleWidthCharWidth(5)
displayBuffer.setDefaultCharWidth(1, 5)
buffer.setText("私たちのフ是一个地方,数千名学生12345业余爱们的板作为우리포럼hello world this is a pretty long latin line")

expect(displayBuffer.tokenizedLineForScreenRow(0).text).toBe("私たちのフ是一个地方")
Expand Down
12 changes: 4 additions & 8 deletions src/display-buffer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,13 @@ class DisplayBuffer extends Model
getLineHeightInPixels: -> @lineHeightInPixels
setLineHeightInPixels: (@lineHeightInPixels) -> @lineHeightInPixels

getDoubleWidthCharWidth: -> @doubleWidthCharWidth
getDefaultCharWidth: -> @defaultCharWidth
setDefaultCharWidth: (defaultCharWidth) ->
if defaultCharWidth isnt @defaultCharWidth
setDefaultCharWidth: (defaultCharWidth, doubleWidthCharWidth=defaultCharWidth) ->
if defaultCharWidth isnt @defaultCharWidth or doubleWidthCharWidth isnt @doubleWidthCharWidth
@defaultCharWidth = defaultCharWidth
defaultCharWidth

getDoubleWidthCharWidth: -> @doubleWidthCharWidth
setDoubleWidthCharWidth: (doubleWidthCharWidth) ->
if doubleWidthCharWidth isnt @doubleWidthCharWidth
@doubleWidthCharWidth = doubleWidthCharWidth
doubleWidthCharWidth
defaultCharWidth

getCursorWidth: -> 1

Expand Down

0 comments on commit 27dc3da

Please sign in to comment.