diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/io/buffer.nim | 21 | ||||
-rw-r--r-- | src/utils/twtstr.nim | 2 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim index 67859b4a..0b8d09a4 100644 --- a/src/io/buffer.nim +++ b/src/io/buffer.nim @@ -318,20 +318,13 @@ proc refreshDisplay(buffer: Buffer) = inc y proc setCursorXB(buffer: Buffer, byte: int) = - assert byte < buffer.currentLine.len - var b = buffer.currentCursorBytes() - assert b < buffer.currentLine.len, $buffer.cursory & " " & $b & " " & $buffer.currentLine.len - var w = buffer.fromx + buffer.cursorx - if b < byte: - while b < byte: - var r: Rune - fastRuneAt(buffer.currentLine, b, r) - w += r.width() - else: - while b > byte: - let (r, o) = lastRune(buffer.currentLine, b) - w -= r.width() - b -= o + var r: Rune + var w = 0 + var b = 0 + while b < byte: + var r: Rune + fastRuneAt(buffer.currentLine, b, r) + w += r.width() let x = w if x - buffer.fromx >= 0 and x - buffer.width < buffer.fromx: diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 6db61fc2..428276f1 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -851,7 +851,7 @@ func width*(s: seq[Rune], min: int): int = inc i func breaksWord*(r: Rune): bool = - return not (r.isDigitAscii() or r.isAlpha() or r.width() == 0) + return not (r.isDigitAscii() or r.width() == 0 or r.isAlpha()) const CanHaveDakuten = "かきくけこさしすせそたちつてとはひふへほカキクケコサシスセソタチツテトハヒフヘホ".toRunes() |