Files
lazygit/pkg/gui/editors_test.go
Stefan HallerandClaude Opus 5.5 e68f195e33 Let a menu's filter receive pasted text in one piece
The filter takes a single line of text. Drop the newlines at the start
and end of the pasted text, and replace the remaining newlines and tabs
with spaces. A pasted newline therefore no longer runs the selected
menu item.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 10:22:50 +01:00

28 lines
574 B
Go

package gui
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPastedTextAsSingleLine(t *testing.T) {
scenarios := []struct {
name string
text string
expected string
}{
{"single line", "foo bar", "foo bar"},
{"newlines at start and end", "\n\nfoo\n", "foo"},
{"newlines inside", "foo\nbar\n\nbaz", "foo bar baz"},
{"tabs", "\tfoo\tbar", " foo bar"},
{"only newlines", "\n\n", ""},
}
for _, s := range scenarios {
t.Run(s.name, func(t *testing.T) {
assert.Equal(t, s.expected, pastedTextAsSingleLine(s.text))
})
}
}