From c4f757e82c5a63111fee03948ec2e50bb44bea0d Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 11 Sep 2025 17:12:04 +0100 Subject: [PATCH] refactor(editor): adjust new editor constructor to be modular --- internal/tui/components/chat/editor/editor.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index 04fb5ed1976c7cf7ba4af372dd16ecef48ceb82f..4778c359ba4cad639b55671a252c4fde98eeab73 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -563,7 +563,7 @@ func yoloPromptFunc(info textarea.PromptInfo) string { return fmt.Sprintf("%s ", t.YoloDotsBlurred) } -func New(app *app.App) Editor { +func newTextArea() *textarea.Model { t := styles.CurrentTheme() ta := textarea.New() ta.SetStyles(t.S().TextArea) @@ -571,10 +571,14 @@ func New(app *app.App) Editor { ta.CharLimit = -1 ta.SetVirtualCursor(false) ta.Focus() - e := &editorCmp{ + return ta +} + +func newEditor(app *app.App) Editor { + e := editorCmp{ // TODO: remove the app instance from here app: app, - textarea: ta, + textarea: newTextArea(), keyMap: DefaultEditorKeyMap(), } e.setEditorPrompt() @@ -582,5 +586,9 @@ func New(app *app.App) Editor { e.randomizePlaceholders() e.textarea.Placeholder = e.readyPlaceholder - return e + return &e +} + +func New(app *app.App) Editor { + return newEditor(app) }