Files
aego/ui/widgets/multiline_image_test.go
sanspie a6822156cd
ci-platforms / windows amd64 smoke (push) Skipped
ci / release (push) Successful in 8m58s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 4m46s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 13m28s
Finish Stage 12 editor fixes and refreshed platformer
2026-11-05 17:36:42 +03:00

27 lines
833 B
Go

package widgets
import (
"testing"
"aego/ui/core"
)
func TestMultilineMarkerAtCaretAndRenumberPreservesSelection(t *testing.T) {
ui := core.New(nil)
var m Multiline
value := "Привет мир"
m.Height(ui, value, 300, 3)
m.b.SetCursor(7, false)
m.Insert(&value, "[Image 1]")
if value != "Привет [Image 1]мир" || m.b.Cursor() != 16 {
t.Fatalf("inserted at the wrong rune: %q cursor=%d", value, m.b.Cursor())
}
m.b.SetCursor(m.b.Len(), false)
if !m.ReplaceFirst(&value, "[Image 1]", "[Image 2]") || m.b.Cursor() != m.b.Len() {
t.Fatalf("renumber moved the caret: %q cursor=%d", value, m.b.Cursor())
}
if !m.ReplaceFirst(&value, "[Image 2]", "") || value != "Привет мир" || m.b.Cursor() != m.b.Len() {
t.Fatalf("removing marker damaged text or caret: %q cursor=%d", value, m.b.Cursor())
}
}