chore(lint): remove custom min and max functions

These are now available as builtins.
This commit is contained in:
Andrey Nering
2025-03-20 10:42:52 -03:00
parent 76433f7143
commit fff86382cc
8 changed files with 9 additions and 102 deletions
+3 -10
View File
@@ -188,10 +188,10 @@ func newStack() stack {
}
}
func (m *Model) pushView(selected, min, max int) {
func (m *Model) pushView(selected, minimum, maximum int) {
m.selectedStack.Push(selected)
m.minStack.Push(min)
m.maxStack.Push(max)
m.minStack.Push(minimum)
m.maxStack.Push(maximum)
}
func (m *Model) popView() (int, int, int) {
@@ -507,10 +507,3 @@ func (m Model) canSelect(file string) bool {
}
return false
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
-7
View File
@@ -1326,10 +1326,3 @@ func countEnabledBindings(groups [][]key.Binding) (agg int) {
}
return agg
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
-7
View File
@@ -212,10 +212,3 @@ func (m Model) dotsView() string {
func (m Model) arabicView() string {
return fmt.Sprintf(m.ArabicFormat, m.Page+1, m.TotalPages)
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
-14
View File
@@ -357,22 +357,8 @@ func (m Model) color(c string) termenv.Color {
return m.colorProfile.Color(c)
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
// IsAnimating returns false if the progress bar reached equilibrium and is no longer animating.
func (m *Model) IsAnimating() bool {
dist := math.Abs(m.percentShown - m.targetPercent)
return !(dist < 0.001 && m.velocity < 0.01)
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
-16
View File
@@ -438,22 +438,6 @@ func (m *Model) renderRow(r int) string {
return row
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func clamp(v, low, high int) int {
return min(max(v, low), high)
}
+6 -20
View File
@@ -853,13 +853,13 @@ func (m Model) LineInfo() LineInfo {
// repositionView repositions the view of the viewport based on the defined
// scrolling behavior.
func (m *Model) repositionView() {
min := m.viewport.YOffset
max := min + m.viewport.Height - 1
minimum := m.viewport.YOffset
maximum := minimum + m.viewport.Height - 1
if row := m.cursorLineNumber(); row < min {
m.viewport.LineUp(min - row)
} else if row > max {
m.viewport.LineDown(row - max)
if row := m.cursorLineNumber(); row < minimum {
m.viewport.LineUp(minimum - row)
} else if row > maximum {
m.viewport.LineDown(row - maximum)
}
}
@@ -1466,17 +1466,3 @@ func clamp(v, low, high int) int {
}
return min(high, max(low, v))
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
-14
View File
@@ -758,20 +758,6 @@ func clamp(v, low, high int) int {
return min(high, max(low, v))
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
// Deprecated.
// Deprecated: use cursor.Mode.
-14
View File
@@ -484,20 +484,6 @@ func clamp(v, low, high int) int {
return min(high, max(low, v))
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
func findLongestLineWidth(lines []string) int {
w := 0
for _, l := range lines {