Skip to content

Commit 04b92b9

Browse files
committed
fix: remove accidental SidebarPathFormatter changes from PR manaflow-ai#2148
PR manaflow-ai#2145 inadvertently included SidebarPathFormatter maxDisplaySegments and shortenedPath truncation logic that belongs to PR manaflow-ai#2148 (sidebar path optimisation). This commit reverts ContentView.swift to origin/main for SidebarPathFormatter while keeping only the mute-related changes: TabItemView == guard, shouldMute/muteLabel vars, mute Button.
1 parent 523360f commit 04b92b9

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

Sources/ContentView.swift

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10855,42 +10855,19 @@ private struct SidebarEmptyArea: View {
1085510855
enum SidebarPathFormatter {
1085610856
static let homeDirectoryPath: String = FileManager.default.homeDirectoryForCurrentUser.path
1085710857

10858-
/// Maximum number of path segments shown before adding a leading ellipsis.
10859-
/// e.g. `~/a/b/c/d` → `…/c/d` when maxSegments == 2.
10860-
static let maxDisplaySegments: Int = 3
10861-
1086210858
static func shortenedPath(
1086310859
_ path: String,
1086410860
homeDirectoryPath: String = Self.homeDirectoryPath
1086510861
) -> String {
1086610862
let trimmed = path.trimmingCharacters(in: .whitespacesAndNewlines)
1086710863
guard !trimmed.isEmpty else { return path }
10868-
10869-
// Replace home directory prefix with ~
10870-
let tildeReplaced: String
1087110864
if trimmed == homeDirectoryPath {
1087210865
return "~"
10873-
} else if trimmed.hasPrefix(homeDirectoryPath + "/") {
10874-
tildeReplaced = "~" + trimmed.dropFirst(homeDirectoryPath.count)
10875-
} else {
10876-
tildeReplaced = trimmed
10877-
}
10878-
10879-
// Apply smart truncation: keep only the last maxDisplaySegments segments
10880-
// so paths with a long common prefix remain distinguishable in the sidebar.
10881-
// e.g. `~/Desktop/YOKE/Claude Code/Projects/Athlete Merch/nilclub`
10882-
// → `…/Projects/Athlete Merch/nilclub`
10883-
let segments = tildeReplaced.split(separator: "/", omittingEmptySubsequences: false)
10884-
// For a tilde-replaced path like `~/a/b/c`, split on "/" yields
10885-
// ["~", "a", "b", "c"]. The tilde token is always a single leading segment.
10886-
// For an absolute path like `/tmp/a/b`, split yields ["", "tmp", "a", "b"].
10887-
// We only truncate when there are strictly more segments than allowed.
10888-
let effectiveMax = maxDisplaySegments + 1 // +1 for the leading "~" or "" token
10889-
guard segments.count > effectiveMax else {
10890-
return tildeReplaced
10891-
}
10892-
let tail = segments.suffix(maxDisplaySegments).joined(separator: "/")
10893-
return "…/" + tail
10866+
}
10867+
if trimmed.hasPrefix(homeDirectoryPath + "/") {
10868+
return "~" + trimmed.dropFirst(homeDirectoryPath.count)
10869+
}
10870+
return trimmed
1089410871
}
1089510872
}
1089610873

0 commit comments

Comments
 (0)