Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

placeholder view Unicode character encoding error #420

Closed
lc-1010 opened this issue Sep 27, 2023 · 4 comments
Closed

placeholder view Unicode character encoding error #420

lc-1010 opened this issue Sep 27, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@lc-1010
Copy link
Contributor

lc-1010 commented Sep 27, 2023

Describe the bug
Placeholder View renders got Unicode character encoding error

Setup
use textinput.Modelset Unicode character is the Placeholder

inputs= textinput.New()
 inputs.Placeholder = "馹ABC"
...
m.input.View()
...
 ���ABC
@meowgorithm meowgorithm added the bug Something isn't working label Sep 27, 2023
@meowgorithm
Copy link
Member

Oooof. Thanks for the report. I'm able to reproduce this (Wezterm, Linux, en_US.UTF-8).

package main

import (
        "fmt"
        "os"

        "github.com/charmbracelet/bubbles/textinput"
        tea "github.com/charmbracelet/bubbletea"
)

type model struct {
        i textinput.Model
}

func (m model) Init() tea.Cmd {
        return m.i.Focus()
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
        switch msg := msg.(type) {
        case tea.KeyMsg:
                if msg.Type == tea.KeyCtrlC || msg.Type == tea.KeyEsc {
                        return m, tea.Quit
                }
        }

        var cmd tea.Cmd
        m.i, cmd = m.i.Update(msg)
        return m, cmd
}

func (m model) View() string {
        return m.i.View() + "\n"
}

func main() {
        i := textinput.New()
        i.Prompt = "> "
        i.Placeholder = "馹ABC"
        m := model{i: i}

        if _, err := tea.NewProgram(m).Run(); err != nil {
                fmt.Println("Error running program:", err)
                os.Exit(1)
        }
}

@lc-1010
Copy link
Contributor Author

lc-1010 commented Sep 28, 2023

You're welcome! I'm glad to hear that you were able to reproduce the issue.

Whenever you have a moment ,could you kindly review and consider merging my PR ? Thank you for your time.
@meowgorithm

@meowgorithm
Copy link
Member

Oh brilliant, I totally missed that you have have a patch. Let's get this done!

@meowgorithm
Copy link
Member

meowgorithm commented Sep 28, 2023

Thank you SO much for both flagging and patching this! 🙌

Fixed by #421.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants