mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
fix mouse scroll events being interpreted as keyboard input (#628)
This commit is contained in:
parent
c663fbc3ee
commit
67aa7ce04d
1 changed files with 20 additions and 1 deletions
|
@ -107,6 +107,25 @@ var BUGGED_SCROLL_KEYS = map[string]bool{
|
|||
";": 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
|
||||
|
@ -114,7 +133,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
switch msg := msg.(type) {
|
||||
case tea.KeyPressMsg:
|
||||
keyString := msg.String()
|
||||
if time.Since(a.lastScroll) < time.Millisecond*100 && BUGGED_SCROLL_KEYS[keyString] {
|
||||
if time.Since(a.lastScroll) < time.Millisecond*100 && (BUGGED_SCROLL_KEYS[keyString] || isScrollRelatedInput(keyString)) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue