Closed tyler-mairose-sp closed 4 days ago
Thanks for filing this issue. I'm able to reproduce the bug.
Here's a minimal example to reproduce the behavior:
package main
import (
"os"
"github.com/charmbracelet/bubbles/textarea"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/log"
)
type model struct {
input textarea.Model
}
func (m model) Init() tea.Cmd {
return m.input.Focus()
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.input.SetWidth(msg.Width)
m.input.SetHeight(msg.Height)
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q", "esc":
return m, tea.Quit
}
}
var cmd tea.Cmd
m.input, cmd = m.input.Update(msg)
return m, cmd
}
func (m model) View() string {
return m.input.View()
}
func main() {
var data []byte
var err error
filepath := "textdata.json"
data, err = os.ReadFile(filepath)
if err != nil {
log.Fatal(err)
}
t := textarea.New()
t.CharLimit = 0
t.SetValue(string(data))
t.Focus()
m := model{input: t}
if _, err := tea.NewProgram(m, tea.WithAltScreen()).Run(); err != nil {
log.Fatal(err)
}
}
@meowgorithm I appreciate the quick turn around. I'll be watching your PR in order to test it out 😄
@meowgorithm I appreciate the quick turn around. I'll be watching your PR in order to test it out 😄
You got it! Just want to get another pair of eyes on it before merging it. There's also a change that needs to happen if you own code: PR here.
Yes thank you! Just out of curiosity what does it do when you set the value first, then the charLimit?
The default character limit is quite small, so if you set the value before removing the character limit the value gets truncated.
We should make a two changes to avoid this pitfall:
Alright, this is fixed. We also removed the default character limit. Let us know if you encounter any more issues.
Cheers!
Describe the bug
I am attempting to create a json path evaluator project using a combination of the bubble tea text input and two text area editors like the split-editors example.
When I load a json file into the text area it does not properly produce the whole string in the text area.
Ultimately, I would like to propose this as a bubble tea example project that others can build from. I thought it was a cool use of the split editors plus a text input.
Setup Please complete the following information along with version numbers, if applicable.
To Reproduce Steps to reproduce the behavior:
go mod tidy
go run main.go
in the terminalSource Code https://github.com/tyler-mairose-sp/json-path-evaluator/tree/main
Expected behavior I would expect the json to be loaded properly into the text area. in reading the docs if
textarea.charLimit
is set to 0 there should be no limit.