From 078424dfb40c5e46d531a43bc7c78c7d2aa0f78a Mon Sep 17 00:00:00 2001 From: Larry Clapp Date: Sun, 19 Mar 2023 16:08:14 -0400 Subject: [PATCH] Set Line.wrapped when a line wraps In Buffer.write(), when CursorColumn() >= Width(), and AutoWrap is on, and you write a new character, set wrapped=true on the new line. --- internal/app/darktile/termutil/buffer.go | 1 + internal/app/darktile/termutil/buffer_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/app/darktile/termutil/buffer.go b/internal/app/darktile/termutil/buffer.go index 7c7ed6d7..0e78d509 100644 --- a/internal/app/darktile/termutil/buffer.go +++ b/internal/app/darktile/termutil/buffer.go @@ -440,6 +440,7 @@ func (buffer *Buffer) write(runes ...MeasuredRune) { buffer.newLineEx(true) newLine := buffer.getCurrentLine() + newLine.wrapped = true if len(newLine.cells) == 0 { newLine.append(buffer.defaultCell(true)) } diff --git a/internal/app/darktile/termutil/buffer_test.go b/internal/app/darktile/termutil/buffer_test.go index fa7a2adc..73cd0a37 100644 --- a/internal/app/darktile/termutil/buffer_test.go +++ b/internal/app/darktile/termutil/buffer_test.go @@ -131,6 +131,7 @@ func TestBufferWriteIncrementsCursorCorrectly(t *testing.T) { writeRaw(b, 'x') require.Equal(t, uint16(1), b.CursorColumn()) require.Equal(t, uint16(1), b.CursorLine()) + require.Equal(t, true, b.getCurrentLine().wrapped) writeRaw(b, 'x') require.Equal(t, uint16(2), b.CursorColumn())