mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
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>
28 lines
574 B
Go
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))
|
|
})
|
|
}
|
|
}
|