mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
fix(textinput): slicing outside cap (#532)
* textinput: fix slicing outside cap * textinput: add test that makes slicing outside cap occur * chore: tidy with gofmt --------- Co-authored-by: bashbunni <bunni@bashbunni.dev>
This commit is contained in:
co-authored by
bashbunni
parent
e5296a2b0f
commit
8624776d45
@@ -700,10 +700,12 @@ func (m Model) View() string {
|
||||
func (m Model) placeholderView() string {
|
||||
var (
|
||||
v string
|
||||
p = []rune(m.Placeholder)
|
||||
style = m.PlaceholderStyle.Inline(true).Render
|
||||
)
|
||||
|
||||
p := make([]rune, m.Width+1)
|
||||
copy(p, []rune(m.Placeholder))
|
||||
|
||||
m.Cursor.TextStyle = m.PlaceholderStyle
|
||||
m.Cursor.SetChar(string(p[:1]))
|
||||
v += m.Cursor.View()
|
||||
|
||||
@@ -30,3 +30,10 @@ func Test_CurrentSuggestion(t *testing.T) {
|
||||
t.Fatalf("Error: expected first suggestion but was %s", suggestion)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_SlicingOutsideCap(t *testing.T) {
|
||||
textinput := New()
|
||||
textinput.Placeholder = "作業ディレクトリを指定してください"
|
||||
textinput.Width = 32
|
||||
textinput.View()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user