diff options
| author | adamdotdevin <[email protected]> | 2025-07-10 15:49:49 -0500 |
|---|---|---|
| committer | adamdotdevin <[email protected]> | 2025-07-10 15:49:58 -0500 |
| commit | 294d0e7ee3476f4425c3d21fbaf82dfce3aba017 (patch) | |
| tree | 3c24c5caf7075612dc58ff4cdb1b1f87eedc2d9b /packages/tui/internal | |
| parent | 8be1ca836c806c5a3ea3f2f5b49a696063dd3a91 (diff) | |
| download | opencode-294d0e7ee3476f4425c3d21fbaf82dfce3aba017.tar.gz opencode-294d0e7ee3476f4425c3d21fbaf82dfce3aba017.zip | |
fix(tui): mouse wheel ansi codes leaking into editor
Diffstat (limited to 'packages/tui/internal')
| -rw-r--r-- | packages/tui/internal/tui/tui.go | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go index ce6e72ff8..512107ffe 100644 --- a/packages/tui/internal/tui/tui.go +++ b/packages/tui/internal/tui/tui.go @@ -11,6 +11,7 @@ import ( "github.com/charmbracelet/bubbles/v2/key" tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/lipgloss/v2" + "github.com/charmbracelet/x/input" "github.com/sst/opencode-sdk-go" "github.com/sst/opencode/internal/app" @@ -74,7 +75,6 @@ type appModel struct { toastManager *toast.ToastManager interruptKeyState InterruptKeyState exitKeyState ExitKeyState - lastScroll time.Time messagesRight bool fileViewer fileviewer.Model lastMouse tea.Mouse @@ -107,44 +107,6 @@ func (a appModel) Init() tea.Cmd { return tea.Batch(cmds...) } -var BUGGED_SCROLL_KEYS = map[string]bool{ - "0": true, - "1": true, - "2": true, - "3": true, - "4": true, - "5": true, - "6": true, - "7": true, - "8": true, - "9": true, - "M": true, - "m": true, - "[": true, - ";": true, - "<": true, -} - -func isScrollRelatedInput(keyString string) bool { - if len(keyString) == 0 { - return false - } - - for _, char := range keyString { - charStr := string(char) - if !BUGGED_SCROLL_KEYS[charStr] { - return false - } - } - - if len(keyString) > 3 && - (keyString[len(keyString)-1] == 'M' || keyString[len(keyString)-1] == 'm') { - return true - } - - return len(keyString) > 1 -} - func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd var cmds []tea.Cmd @@ -153,10 +115,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyPressMsg: keyString := msg.String() - if time.Since(a.lastScroll) < time.Millisecond*100 && (BUGGED_SCROLL_KEYS[keyString] || isScrollRelatedInput(keyString)) { - return a, nil - } - // 1. Handle active modal if a.modal != nil { switch keyString { @@ -326,7 +284,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { a.editor = updatedEditor.(chat.EditorComponent) return a, cmd case tea.MouseWheelMsg: - a.lastScroll = time.Now() if a.modal != nil { return a, nil } @@ -552,6 +509,8 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { a.editor.SetExitKeyInDebounce(false) case dialog.FindSelectedMsg: return a.openFile(msg.FilePath) + case input.UnknownEvent: + return a, nil } s, cmd := a.status.Update(msg) |
