mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-10-19 00:49:54 +03:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7ecce3fb97 | ||
|
746834a7ce | ||
|
fd306528f9 | ||
|
a4dc540f3d | ||
|
151d1026dd |
@@ -412,6 +412,11 @@ func (m *Model) deleteWordLeft() bool {
|
|||||||
return m.deleteBeforeCursor()
|
return m.deleteBeforeCursor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linter note: it's critical that we acquire the initial cursor position
|
||||||
|
// here prior to altering it via SetCursor() below. As such, moving this
|
||||||
|
// call into the corresponding if clause does not apply here.
|
||||||
|
oldPos := m.pos //nolint:ifshort
|
||||||
|
|
||||||
blink := m.setCursor(m.pos - 1)
|
blink := m.setCursor(m.pos - 1)
|
||||||
for unicode.IsSpace(m.value[m.pos]) {
|
for unicode.IsSpace(m.value[m.pos]) {
|
||||||
if m.pos <= 0 {
|
if m.pos <= 0 {
|
||||||
@@ -433,10 +438,10 @@ func (m *Model) deleteWordLeft() bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.pos > len(m.value) {
|
if oldPos > len(m.value) {
|
||||||
m.value = m.value[:m.pos]
|
m.value = m.value[:m.pos]
|
||||||
} else {
|
} else {
|
||||||
m.value = append(m.value[:m.pos], m.value[m.pos:]...)
|
m.value = append(m.value[:m.pos], m.value[oldPos:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return blink
|
return blink
|
||||||
@@ -454,7 +459,7 @@ func (m *Model) deleteWordRight() bool {
|
|||||||
return m.deleteAfterCursor()
|
return m.deleteAfterCursor()
|
||||||
}
|
}
|
||||||
|
|
||||||
i := m.pos
|
oldPos := m.pos
|
||||||
m.setCursor(m.pos + 1)
|
m.setCursor(m.pos + 1)
|
||||||
for unicode.IsSpace(m.value[m.pos]) {
|
for unicode.IsSpace(m.value[m.pos]) {
|
||||||
// ignore series of whitespace after cursor
|
// ignore series of whitespace after cursor
|
||||||
@@ -474,12 +479,12 @@ func (m *Model) deleteWordRight() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m.pos > len(m.value) {
|
if m.pos > len(m.value) {
|
||||||
m.value = m.value[:i]
|
m.value = m.value[:oldPos]
|
||||||
} else {
|
} else {
|
||||||
m.value = append(m.value[:i], m.value[m.pos:]...)
|
m.value = append(m.value[:oldPos], m.value[m.pos:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.setCursor(i)
|
return m.setCursor(oldPos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// wordLeft moves the cursor one word to the left. Returns whether or not the
|
// wordLeft moves the cursor one word to the left. Returns whether or not the
|
||||||
@@ -795,6 +800,9 @@ func Paste() tea.Msg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func clamp(v, low, high int) int {
|
func clamp(v, low, high int) int {
|
||||||
|
if high < low {
|
||||||
|
low, high = high, low
|
||||||
|
}
|
||||||
return min(high, max(low, v))
|
return min(high, max(low, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -358,7 +358,10 @@ func (m Model) View() string {
|
|||||||
extraLines = strings.Repeat("\n", max(0, m.Height-len(lines)))
|
extraLines = strings.Repeat("\n", max(0, m.Height-len(lines)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.Style.Render(strings.Join(lines, "\n") + extraLines)
|
return m.Style.Copy().
|
||||||
|
UnsetWidth().
|
||||||
|
UnsetHeight().
|
||||||
|
Render(strings.Join(lines, "\n") + extraLines)
|
||||||
}
|
}
|
||||||
|
|
||||||
func clamp(v, low, high int) int {
|
func clamp(v, low, high int) int {
|
||||||
|
Reference in New Issue
Block a user