mirror of
https://github.com/Maks1mS/bubbles.git
synced 2024-12-24 14:44:38 +03:00
Support Alt-Backspace to delete previous word
This commit is contained in:
parent
5dbcf95877
commit
97020cd0d2
@ -418,10 +418,14 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
|||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch msg.Type {
|
switch msg.Type {
|
||||||
case tea.KeyBackspace: // delete character before cursor
|
case tea.KeyBackspace: // delete character before cursor
|
||||||
if len(m.value) > 0 {
|
if msg.Alt {
|
||||||
m.value = append(m.value[:max(0, m.pos-1)], m.value[m.pos:]...)
|
m.deleteWordLeft()
|
||||||
if m.pos > 0 {
|
} else {
|
||||||
m.SetCursor(m.pos - 1)
|
if len(m.value) > 0 {
|
||||||
|
m.value = append(m.value[:max(0, m.pos-1)], m.value[m.pos:]...)
|
||||||
|
if m.pos > 0 {
|
||||||
|
m.SetCursor(m.pos - 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case tea.KeyLeft:
|
case tea.KeyLeft:
|
||||||
|
Loading…
Reference in New Issue
Block a user