mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Take double width chars into account when soft wrapping
This commit is contained in:
@@ -195,6 +195,12 @@ class DisplayBuffer extends Model
|
||||
@defaultCharWidth = defaultCharWidth
|
||||
defaultCharWidth
|
||||
|
||||
getDoubleWidthCharWidth: -> @doubleWidthCharWidth
|
||||
setDoubleWidthCharWidth: (doubleWidthCharWidth) ->
|
||||
if doubleWidthCharWidth isnt @doubleWidthCharWidth
|
||||
@doubleWidthCharWidth = doubleWidthCharWidth
|
||||
doubleWidthCharWidth
|
||||
|
||||
getCursorWidth: -> 1
|
||||
|
||||
scrollToScreenRange: (screenRange, options = {}) ->
|
||||
@@ -282,8 +288,13 @@ class DisplayBuffer extends Model
|
||||
else
|
||||
charLength = 1
|
||||
|
||||
charWidth = @getDefaultCharWidth()
|
||||
if iterator.hasDoubleWidthCharacterAt(textIndex)
|
||||
charWidth = @getDoubleWidthCharWidth()
|
||||
else
|
||||
charWidth = @getDefaultCharWidth()
|
||||
|
||||
return column if currentWidth + charWidth > lineMaxWidth
|
||||
|
||||
currentWidth += charWidth
|
||||
column += charLength
|
||||
textIndex += charLength
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{SoftTab, HardTab, PairedCharacter, SoftWrapIndent} = require './special-token-symbols'
|
||||
{isDoubleWidthCharacter} = require './text-utils'
|
||||
|
||||
module.exports =
|
||||
class TokenIterator
|
||||
@@ -82,5 +83,8 @@ class TokenIterator
|
||||
isPairedCharacter: ->
|
||||
@line.specialTokens[@index] is PairedCharacter
|
||||
|
||||
hasDoubleWidthCharacterAt: (charIndex) ->
|
||||
isDoubleWidthCharacter(@getText()[charIndex])
|
||||
|
||||
isAtomic: ->
|
||||
@isSoftTab() or @isHardTab() or @isSoftWrapIndentation() or @isPairedCharacter()
|
||||
|
||||
Reference in New Issue
Block a user