diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 63ed01f..271179a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,6 +13,10 @@ updates: commit-message: prefix: "chore" include: "scope" + groups: + all: + patterns: + - "*" - package-ecosystem: "github-actions" directory: "/" @@ -26,6 +30,10 @@ updates: commit-message: prefix: "chore" include: "scope" + groups: + all: + patterns: + - "*" - package-ecosystem: "docker" directory: "/" @@ -39,3 +47,7 @@ updates: commit-message: prefix: "chore" include: "scope" + groups: + all: + patterns: + - "*" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72bed38..18f695c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,12 +11,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Download Go modules run: go mod download diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 40a4bf1..f230a78 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,12 +12,12 @@ jobs: GO111MODULE: "on" steps: - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Coverage env: diff --git a/LICENSE b/LICENSE index 31d76c1..be3f0c1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2023 Charmbracelet, Inc +Copyright (c) 2020-2025 Charmbracelet, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 1ea295c..a19d41e 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,6 @@ We’d love to hear your thoughts on this project. Feel free to drop us a note! Part of [Charm](https://charm.sh). -The Charm logo +The Charm logo Charm热爱开源 • Charm loves open source diff --git a/textinput/textinput_test.go b/textinput/textinput_test.go index 3bfb958..b9ea4c2 100644 --- a/textinput/textinput_test.go +++ b/textinput/textinput_test.go @@ -5,6 +5,8 @@ import ( "strconv" "strings" "testing" + + tea "github.com/charmbracelet/bubbletea" ) func Test_CurrentSuggestion(t *testing.T) { @@ -46,6 +48,30 @@ func Test_SlicingOutsideCap(t *testing.T) { textinput.View() } +func TestChinesePlaceholder(t *testing.T) { + textinput := New() + textinput.Placeholder = "输入消息..." + textinput.Width = 20 + + got := textinput.View() + expected := "> 输入消息... " + if got != expected { + t.Fatalf("expected %q but got %q", expected, got) + } +} + +func TestPlaceholderTruncate(t *testing.T) { + textinput := New() + textinput.Placeholder = "A very long placeholder, or maybe not so much" + textinput.Width = 10 + + got := textinput.View() + expected := "> A very …" + if got != expected { + t.Fatalf("expected %q but got %q", expected, got) + } +} + func ExampleValidateFunc() { creditCardNumber := New() creditCardNumber.Placeholder = "4505 **** **** 1234" @@ -78,3 +104,15 @@ func ExampleValidateFunc() { return err } } + +func keyPress(key rune) tea.Msg { + return tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{key}, Alt: false} +} + +func sendString(m Model, str string) Model { + for _, k := range str { + m, _ = m.Update(keyPress(k)) + } + + return m +}