rebase branch

This commit is contained in:
Roman Suvorov
2024-12-14 18:43:36 +01:00
committed by Roman Suvorov
parent 98ba87b817
commit fe8d41e8bb
+3 -15
View File
@@ -7,6 +7,7 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/mattn/go-runewidth"
)
// New returns a new model with the given width and height as well as default
@@ -132,7 +133,7 @@ func (m Model) visibleLines() (lines []string) {
if m.indent > 0 {
cutLines := make([]string, len(lines))
for i := range lines {
cutLines[i] = getStringWithIndent(lines[i], m.indent)
cutLines[i] = runewidth.TruncateLeft(lines[i], m.indent, "")
}
return cutLines
@@ -309,7 +310,7 @@ func ViewUp(m Model, lines []string) tea.Cmd {
// Must be set before `MoveLeft` or `MoveRight` is used.
// If 0 or negative, left/right movement doesn't work.
func (m *Model) SetHorizontalStep(n int) {
if n < 1 {
if n < 0 {
n = 0
}
@@ -469,16 +470,3 @@ func max(a, b int) int {
}
return b
}
func getStringWithIndent(s string, indent int) string {
if indent == 0 {
return s
}
r := []rune(s)
if indent > len(r) {
return ""
}
return string(r[indent:])
}