mirror of https://github.com/rivo/tview.git
Bugfixes related to zero-width joiners.
This commit is contained in:
parent
a677b985cc
commit
bc39bf8d24
|
@ -938,7 +938,7 @@ func (t *TextView) Draw(screen tcell.Screen) {
|
|||
runeSequence = append(runeSequence, ch)
|
||||
continue
|
||||
}
|
||||
} else if runeSequence[len(runeSequence)-1] == '\u200d' {
|
||||
} else if len(runeSequence) > 0 && runeSequence[len(runeSequence)-1] == '\u200d' {
|
||||
// Keep collecting if the previous character was a zero-width joiner.
|
||||
runeSequence = append(runeSequence, ch)
|
||||
continue
|
||||
|
|
13
util.go
13
util.go
|
@ -388,10 +388,15 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
|
|||
ch = ' '
|
||||
chWidth = 1
|
||||
}
|
||||
} else if len(runeSequence) > 0 && runeSequence[len(runeSequence)-1] != '\u200d' {
|
||||
// We have a character that doesn't follow a zero-width joiner. Flush all
|
||||
// previous runes.
|
||||
flush()
|
||||
} else if len(runeSequence) > 0 {
|
||||
if runeSequence[len(runeSequence)-1] != '\u200d' {
|
||||
// We have a character that doesn't follow a zero-width joiner. Flush all
|
||||
// previous runes.
|
||||
flush()
|
||||
} else {
|
||||
// Characters after zero-width joiners have zero width.
|
||||
chWidth = 0
|
||||
}
|
||||
}
|
||||
runeSequence = append(runeSequence, ch)
|
||||
runeSeqWidth += chWidth
|
||||
|
|
Loading…
Reference in New Issue