gofmt: format all remaining files with the go1.27 toolchain

The tree was formatted with an older gofmt; go1.27's gofmt additionally
wants: EOF exactly one newline (no trailing blank lines), imports sorted
alphabetically within a block, mixed-precedence binary expressions
re-spaced for grouping ((a+b)/c), single-field composite literals
un-aligned, adjacent one-line method signatures aligned, and one-line
bodies containing a compound statement expanded. Applied repo-wide
(31 files under internal/); pure formatting, no semantic changes —
build and the full test suite pass.
This commit is contained in:
gmp
2026-08-23 10:03:27 -04:00
parent 180fa966c8
commit 06b1444207
31 changed files with 279 additions and 247 deletions
+1 -2
View File
@@ -66,7 +66,7 @@ func computeVisiblePageRange(s *BrowserState) (minPage, maxPage int) {
if minPage < 0 {
minPage = 0
}
maxPage = (s.GetScrollIndex() + s.VisibleCount)/PageSize + PrefetchDist
maxPage = (s.GetScrollIndex()+s.VisibleCount)/PageSize + PrefetchDist
return minPage, maxPage
}
@@ -164,4 +164,3 @@ func filterEntriesByQuery(entries []Entry, query string) []int {
return results
}
+5 -5
View File
@@ -28,7 +28,7 @@ func TestLoadPage_FromIndexAtOffset(t *testing.T) {
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: allEntries,
Entries: allEntries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(allEntries, SortModeNameAsc),
"date_desc": buildPositionMap(allEntries, SortModeDateDesc),
@@ -76,7 +76,7 @@ func TestLoadPage_LastPagePartialFromIndex(t *testing.T) {
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: allEntries,
Entries: allEntries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(allEntries, SortModeNameAsc),
"date_desc": buildPositionMap(allEntries, SortModeDateDesc),
@@ -116,7 +116,7 @@ func TestLoadPage_OutOfBoundsFromIndex(t *testing.T) {
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: allEntries,
Entries: allEntries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(allEntries, SortModeNameAsc),
"date_desc": buildPositionMap(allEntries, SortModeDateDesc),
@@ -195,7 +195,7 @@ func TestGetEntryByIndex(t *testing.T) {
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: allEntries,
Entries: allEntries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(allEntries, SortModeNameAsc),
"date_desc": buildPositionMap(allEntries, SortModeDateDesc),
@@ -236,7 +236,7 @@ func TestGetEntryByIndex_UnloadedPage(t *testing.T) {
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: allEntries,
Entries: allEntries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(allEntries, SortModeNameAsc),
"date_desc": buildPositionMap(allEntries, SortModeDateDesc),
+5 -5
View File
@@ -13,11 +13,11 @@ import (
// DirectoryIndex holds a cached index of a directory's contents.
// Per design: index stores raw metadata; sorting is pre-computed via position maps.
type DirectoryIndex struct {
Path string `json:"path"`
Mtime time.Time `json:"mtime"`
EntryCount int `json:"entry_count"`
Entries []Entry `json:"entries"`
SortOrders map[string][]int `json:"sort_orders,omitempty"` // key: "name_asc", "name_desc", etc.
Path string `json:"path"`
Mtime time.Time `json:"mtime"`
EntryCount int `json:"entry_count"`
Entries []Entry `json:"entries"`
SortOrders map[string][]int `json:"sort_orders,omitempty"` // key: "name_asc", "name_desc", etc.
}
// getCachePath returns the path to the cached index file for a directory.
-2
View File
@@ -224,5 +224,3 @@ func TestBuildIndex_LargeDirectory(t *testing.T) {
t.Errorf("buildIndex took %v, expected < 5s", elapsed)
}
}
+1 -3
View File
@@ -160,8 +160,6 @@ func recomputeSearchResults(s *BrowserState) {
}
}
// ComputeVisibleEntriesForTest is exported for testing purposes.
// It builds the list of ui.ListItem entries that should be rendered.
func ComputeVisibleEntriesForTest(state *BrowserState) []ui.ListItem {
@@ -224,7 +222,7 @@ func computeSearchResults(state *BrowserState) []ui.ListItem {
var items []ui.ListItem
for idx := startIndex; idx < endIndex; idx++ {
rawIdx := state.SearchResults[idx]
entry, ok := getEntryByIndex(state, rawIdx)
if !ok {
// Page not loaded yet; add placeholder
+1 -1
View File
@@ -32,7 +32,7 @@ func makeTestState(t *testing.T, entryCount int, scrollIndex int, visibleCount i
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: entries,
Entries: entries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(entries, SortModeNameAsc),
"date_desc": buildPositionMap(entries, SortModeDateDesc),
+1 -1
View File
@@ -67,7 +67,7 @@ func TestLazyLoadingLargeDirectory(t *testing.T) {
// 3. Scroll down to page 50
state.ScrollOffset = 50 * 100 * state.EntryHeight // Scroll to middle
bm.OnScroll()
// Wait for load pages result for scroll
res, ok = getResult(15 * time.Second)
if !ok {
+2 -2
View File
@@ -145,7 +145,7 @@ func TestPixelScroll_EvictionTriggered(t *testing.T) {
entries[i] = NewEntry("/test/file.txt", "file.txt", 100, s.TapTimestamp, false)
}
s.SortIndex = &DirectoryIndex{
Entries: entries,
Entries: entries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(entries, SortModeNameAsc),
"date_desc": buildPositionMap(entries, SortModeDateDesc),
@@ -184,7 +184,7 @@ func TestPixelScroll_PrefetchTriggered(t *testing.T) {
entries[i] = NewEntry("/test/file.txt", "file.txt", 100, s.TapTimestamp, false)
}
s.SortIndex = &DirectoryIndex{
Entries: entries,
Entries: entries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(entries, SortModeNameAsc),
"date_desc": buildPositionMap(entries, SortModeDateDesc),
+3 -3
View File
@@ -83,7 +83,7 @@ func TestScroll_PrefetchTriggered(t *testing.T) {
}
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: entries,
Entries: entries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(entries, SortModeNameAsc),
"date_desc": buildPositionMap(entries, SortModeDateDesc),
@@ -131,7 +131,7 @@ func TestScroll_EvictionTriggered(t *testing.T) {
}
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: entries,
Entries: entries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(entries, SortModeNameAsc),
"date_desc": buildPositionMap(entries, SortModeDateDesc),
@@ -246,7 +246,7 @@ func TestScroll_PrefetchTriggeredOnPageBoundary(t *testing.T) {
}
// Build position maps for sort modes
s.SortIndex = &DirectoryIndex{
Entries: entries,
Entries: entries,
SortOrders: map[string][]int{
"name_asc": buildPositionMap(entries, SortModeNameAsc),
"date_desc": buildPositionMap(entries, SortModeDateDesc),
+1 -1
View File
@@ -171,7 +171,7 @@ func TestSearch_JumpToFirst(t *testing.T) {
if len(s.SearchResults) == 0 {
t.Fatalf("expected results for 'file_3', got 0")
}
// The first result should be index 3 (file_3).
// With 12 results, it fits in 20 visible. ScrollIndex should be 0.
if s.GetScrollIndex() != 0 {
-1
View File
@@ -69,4 +69,3 @@ func comparator(mode SortMode) func(a, b Entry) int {
return func(a, b Entry) int { return 0 }
}
}
+15 -15
View File
@@ -19,20 +19,20 @@ type Entry struct {
// Page represents a chunk of directory entries loaded from disk.
type Page struct {
Index int // Page number (0-based)
Entries []Entry // Entries in this page
Loaded bool // True if page data is in memory
Dirty bool // True if page needs refresh (external change detected)
Index int // Page number (0-based)
Entries []Entry // Entries in this page
Loaded bool // True if page data is in memory
Dirty bool // True if page needs refresh (external change detected)
}
// BrowserState holds all mutable browser state owned by the logic goroutine.
type BrowserState struct {
// Navigation
CurrentPath string // Currently browsed directory (relative to root)
History []string // Path history for navigation
ScrollOffset float64 // Vertical scroll offset in pixels (per-pixel scrolling)
EntryHeight float64 // Height of a single entry in pixels
VisibleCount int // Number of entries currently visible
CurrentPath string // Currently browsed directory (relative to root)
History []string // Path history for navigation
ScrollOffset float64 // Vertical scroll offset in pixels (per-pixel scrolling)
EntryHeight float64 // Height of a single entry in pixels
VisibleCount int // Number of entries currently visible
// Lazy loading
Pages map[int]*Page // Loaded pages by page index
@@ -44,8 +44,8 @@ type BrowserState struct {
SortMode SortMode // Current sort mode
// Search
Query string // Current search query (forwarded from the main-owned search widget)
SearchResults []int // Indices of matching entries (empty = no filter)
Query string // Current search query (forwarded from the main-owned search widget)
SearchResults []int // Indices of matching entries (empty = no filter)
// NOTE: the search bar's widget.Editor is intentionally NOT part of this
// state: Gio mutates widget state on the main goroutine during draw, and
// this state is owned by the logic goroutine (architecture.md §1). The
@@ -62,8 +62,8 @@ type BrowserState struct {
}
const (
PageSize = 100 // Entries per page (tunable; ~5KB per page in memory)
PrefetchDist = 2 // Pages to prefetch beyond visible region
PageSize = 100 // Entries per page (tunable; ~5KB per page in memory)
PrefetchDist = 2 // Pages to prefetch beyond visible region
)
// NewEntry creates a new Entry from the given parameters.
@@ -127,10 +127,10 @@ func formatSize(bytes int64) string {
// EvictPages removes pages that are far from the current scroll position.
func (s *BrowserState) EvictPages() {
minPage := s.GetScrollIndex()/PageSize - PrefetchDist
maxPage := (s.GetScrollIndex() + s.VisibleCount)/PageSize + PrefetchDist
maxPage := (s.GetScrollIndex()+s.VisibleCount)/PageSize + PrefetchDist
for idx, page := range s.Pages {
if idx < minPage || idx > maxPage {
page.Entries = nil // Release memory
page.Entries = nil // Release memory
page.Loaded = false
}
}
+6 -6
View File
@@ -103,7 +103,7 @@ func TestFormatSize(t *testing.T) {
{0, "0 B"},
{500, "500 B"},
{1024, "1.0 KB"},
{1024*1024, "1.0 MB"},
{1024 * 1024, "1.0 MB"},
{1024 * 1024 * 1024, "1.0 GB"},
}
@@ -118,7 +118,7 @@ func TestFormatSize(t *testing.T) {
func TestBrowserStateEvictPages(t *testing.T) {
s := NewBrowserState()
s.EntryHeight = 48.0
s.ScrollOffset = 500 * 48 // Page 5
s.ScrollOffset = 500 * 48 // Page 5
s.VisibleCount = 10
// With ScrollIndex=500, PageSize=100:
@@ -127,10 +127,10 @@ func TestBrowserStateEvictPages(t *testing.T) {
// Pages 3-7 should be kept, others evicted
// Add pages at various positions
s.Pages[0] = NewPage(0, nil) // Should be evicted (far)
s.Pages[3] = NewPage(3, nil) // Should be kept (at min boundary)
s.Pages[5] = NewPage(5, nil) // Should be kept (visible)
s.Pages[7] = NewPage(7, nil) // Should be kept (at max boundary)
s.Pages[0] = NewPage(0, nil) // Should be evicted (far)
s.Pages[3] = NewPage(3, nil) // Should be kept (at min boundary)
s.Pages[5] = NewPage(5, nil) // Should be kept (visible)
s.Pages[7] = NewPage(7, nil) // Should be kept (at max boundary)
s.Pages[10] = NewPage(10, nil) // Should be evicted (far)
s.EvictPages()