1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 07:35:07 +00:00

refactor: modernize Go code

This commit is contained in:
Oleksandr Redko
2026-01-06 11:52:05 +02:00
parent 62ef283943
commit 158af1e1ba
12 changed files with 55 additions and 119 deletions

View File

@@ -100,14 +100,8 @@ func (m model) View() string {
fmt.Fprintln(&b, " No large files found (>=100MB)")
} else {
viewport := calculateViewport(m.height, true)
start := m.largeOffset
if start < 0 {
start = 0
}
end := start + viewport
if end > len(m.largeFiles) {
end = len(m.largeFiles)
}
start := max(m.largeOffset, 0)
end := min(start+viewport, len(m.largeFiles))
maxLargeSize := int64(1)
for _, file := range m.largeFiles {
if file.Size > maxLargeSize {
@@ -163,10 +157,7 @@ func (m model) View() string {
for idx, entry := range m.entries {
icon := "📁"
sizeVal := entry.Size
barValue := sizeVal
if barValue < 0 {
barValue = 0
}
barValue := max(sizeVal, 0)
var percent float64
if totalSize > 0 && sizeVal >= 0 {
percent = float64(sizeVal) / float64(totalSize) * 100
@@ -243,14 +234,8 @@ func (m model) View() string {
viewport := calculateViewport(m.height, false)
nameWidth := calculateNameWidth(m.width)
start := m.offset
if start < 0 {
start = 0
}
end := start + viewport
if end > len(m.entries) {
end = len(m.entries)
}
start := max(m.offset, 0)
end := min(start+viewport, len(m.entries))
for idx := start; idx < end; idx++ {
entry := m.entries[idx]