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

fix textinput infinite loop and panic #89

Merged
merged 1 commit into from Jan 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions textinput/textinput.go
Expand Up @@ -410,6 +410,9 @@ func (m *Model) deleteWordLeft() bool {
i := m.pos
blink := m.setCursor(m.pos - 1)
for unicode.IsSpace(m.value[m.pos]) {
if m.pos <= 0 {
break
}
// ignore series of whitespace before cursor
blink = m.setCursor(m.pos - 1)
}
Expand Down Expand Up @@ -452,6 +455,10 @@ func (m *Model) deleteWordRight() bool {
for unicode.IsSpace(m.value[m.pos]) {
// ignore series of whitespace after cursor
m.setCursor(m.pos + 1)

if m.pos >= len(m.value) {
break
}
}

for m.pos < len(m.value) {
Expand Down