Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Show and copy a folder's whole path without a slash at the end
Țugui Dragoșed7593a0d4e5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 07e6675e..a55c0564 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -764,6 +764,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.#### Every page+- A folder's whole path, in a row's tooltip and in Copy Path, no longer ends in a slash, as Finder copies it.- Peel no longer stops responding for good when a checkbox in a list changes on its own, as at the end of a Move to Trashthat kept an item, while an app that reads other apps' windows through accessibility is running.- With Reduce Motion on, figures fade to their new value instead of rolling, on Home, in the menu bar panel, and in thediff --git a/Packages/PeelCore/Tests/PeelCoreTests/InflectionMarkupTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InflectionMarkupTests.swiftindex a78defa7..885bf768 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/InflectionMarkupTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/InflectionMarkupTests.swift@@ -31,4 +31,18 @@ struct InflectionMarkupTests {}#expect(found.isEmpty, "SwiftUI rolls digits under Reduce Motion too; use numberTransition(value:)")}++ @Test func aPathThePersonSeesOrCopiesEndsWithoutASlash() throws {+ let raw = ".path(percentEncoded: false)"+ let shown = ["Text(verbatim:", "setString(", "explanation)\""]+ let root = LineLengthTests.repository.path(percentEncoded: false)+ var found: [String] = []+ for file in try LineLengthTests.swiftFiles() where file.path(percentEncoded: false).contains("/Peel/Views/") {+ let lines = try String(contentsOf: file, encoding: .utf8).split(separator: "\n")+ for (index, line) in lines.enumerated() where line.contains(raw) && shown.contains(where: line.contains) {+ found.append("\(file.path(percentEncoded: false).dropFirst(root.count)):\(index + 1)")+ }+ }+ #expect(found.isEmpty, "A folder's URL keeps its slash in path(percentEncoded:); use fullPath: \(found)")+ }}diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swiftindex 93a043c7..6eaf5edf 100644--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift@@ -88,7 +88,7 @@ struct BackgroundItemDetailView: View {LabeledContent("Configuration file") {Text(verbatim: plist.abbreviatedPath).textSelection(.enabled)- .help(Text(verbatim: plist.path(percentEncoded: false)))+ .help(Text(verbatim: plist.fullPath))if finderURL == plist {ShowInFinderButton(url: plist)}diff --git a/Peel/Views/Duplicates/DuplicateFolderGroupView.swift b/Peel/Views/Duplicates/DuplicateFolderGroupView.swiftindex ad438f43..1235d8a7 100644--- a/Peel/Views/Duplicates/DuplicateFolderGroupView.swift+++ b/Peel/Views/Duplicates/DuplicateFolderGroupView.swift@@ -110,7 +110,7 @@ private struct DuplicateFolderRow: View {}.toggleStyle(.checkbox).disabled(!canChangeSelection)- .help(canChangeSelection ? Text(verbatim: folder.url.path(percentEncoded: false)) : Text("Peel always keeps at least one copy."))+ .help(canChangeSelection ? Text(verbatim: folder.url.fullPath) : Text("Peel always keeps at least one copy."))}.tableRow(isFirst: isFirst).contextMenu {diff --git a/Peel/Views/Duplicates/DuplicateGroupView.swift b/Peel/Views/Duplicates/DuplicateGroupView.swiftindex c6b865f7..7a5b4355 100644--- a/Peel/Views/Duplicates/DuplicateGroupView.swift+++ b/Peel/Views/Duplicates/DuplicateGroupView.swift@@ -161,7 +161,7 @@ private struct DuplicateFileRow: View {}.toggleStyle(.checkbox).disabled(!canChangeSelection)- .help(canChangeSelection ? Text(verbatim: file.url.path(percentEncoded: false)) : Text("Peel always keeps at least one copy."))+ .help(canChangeSelection ? Text(verbatim: file.url.fullPath) : Text("Peel always keeps at least one copy."))Button {preview.url = file.urldiff --git a/Peel/Views/Extensions/ExtensionDetailView.swift b/Peel/Views/Extensions/ExtensionDetailView.swiftindex 37391fac..88f6b4b9 100644--- a/Peel/Views/Extensions/ExtensionDetailView.swift+++ b/Peel/Views/Extensions/ExtensionDetailView.swift@@ -97,7 +97,7 @@ struct ExtensionDetailView: View {.lineLimit(1).truncationMode(.middle).textSelection(.enabled)- .help(Text(verbatim: url.path(percentEncoded: false)))+ .help(Text(verbatim: url.fullPath))} header: {Text("Where")}diff --git a/Peel/Views/FileSearch/FileSearchFileView.swift b/Peel/Views/FileSearch/FileSearchFileView.swiftindex fb92af14..a09c2b23 100644--- a/Peel/Views/FileSearch/FileSearchFileView.swift+++ b/Peel/Views/FileSearch/FileSearchFileView.swift@@ -25,7 +25,7 @@ struct FileSearchFileView: View {LabeledContent("Where") {Text(verbatim: file.url.abbreviatedPath).textSelection(.enabled)- .help(Text(verbatim: file.url.path(percentEncoded: false)))+ .help(Text(verbatim: file.url.fullPath))ShowInFinderButton(url: file.url)}.labeledContentStyle(.oneLine)diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swiftindex 49884d9a..6df500a0 100644--- a/Peel/Views/History/HistoryDetailView.swift+++ b/Peel/Views/History/HistoryDetailView.swift@@ -272,7 +272,7 @@ private struct HistoryRecordRow: View {}Button("Copy Path", systemImage: "doc.on.doc") {NSPasteboard.general.clearContents()- NSPasteboard.general.setString(record.originalURL.path(percentEncoded: false), forType: .string)+ NSPasteboard.general.setString(record.originalURL.fullPath, forType: .string)}}}@@ -298,7 +298,7 @@ private struct HistoryRecordRow: View {Text(record.originalURL.abbreviatedPath).lineLimit(1).truncationMode(.middle)- .help(Text(verbatim: record.originalURL.path(percentEncoded: false)))+ .help(Text(verbatim: record.originalURL.fullPath)).checkboxTitleLine()Text(place.title).font(.caption)diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swiftindex 25002f56..28d39204 100644--- a/Peel/Views/Homebrew/HomebrewList.swift+++ b/Peel/Views/Homebrew/HomebrewList.swift@@ -245,7 +245,7 @@ struct HomebrewList: View {}LabeledContent("Location") {let location =- homebrew.installation?.prefix.path(percentEncoded: false)+ homebrew.installation?.prefix.fullPath?? String(localized: "Unknown (Homebrew location)", defaultValue: "Unknown")Text(verbatim: location).font(.callout.monospaced())diff --git a/Peel/Views/Intel/IntelDetailView.swift b/Peel/Views/Intel/IntelDetailView.swiftindex 4ce979c7..507c9b05 100644--- a/Peel/Views/Intel/IntelDetailView.swift+++ b/Peel/Views/Intel/IntelDetailView.swift@@ -83,7 +83,7 @@ struct IntelDetailView: View {LabeledContent("Where") {Text(verbatim: finding.url.abbreviatedPath).textSelection(.enabled)- .help(Text(verbatim: finding.url.path(percentEncoded: false)))+ .help(Text(verbatim: finding.url.fullPath))ShowInFinderButton(url: finding.url)}.labeledContentStyle(.oneLine)diff --git a/Peel/Views/ItemMenu.swift b/Peel/Views/ItemMenu.swiftindex be744ad9..876d270c 100644--- a/Peel/Views/ItemMenu.swift+++ b/Peel/Views/ItemMenu.swift@@ -28,7 +28,7 @@ struct ItemMenu: View {}Button("Copy Path", systemImage: "doc.on.doc") {NSPasteboard.general.clearContents()- NSPasteboard.general.setString(url.path(percentEncoded: false), forType: .string)+ NSPasteboard.general.setString(url.fullPath, forType: .string)}Divider()if isExcluded {diff --git a/Peel/Views/Plugins/PluginDetailView.swift b/Peel/Views/Plugins/PluginDetailView.swiftindex c99974bc..deb464ed 100644--- a/Peel/Views/Plugins/PluginDetailView.swift+++ b/Peel/Views/Plugins/PluginDetailView.swift@@ -65,7 +65,7 @@ struct PluginDetailView: View {LabeledContent("Location") {Text(verbatim: plugin.url.abbreviatedPath).textSelection(.enabled)- .help(Text(verbatim: plugin.url.path(percentEncoded: false)))+ .help(Text(verbatim: plugin.url.fullPath))ShowInFinderButton(url: plugin.url)}.labeledContentStyle(.oneLine)diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 0ffb9dcc..a71ac349 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -532,6 +532,12 @@ extension URL {var abbreviatedPath: String {(path(percentEncoded: false) as NSString).abbreviatingWithTildeInPath}++ /// The whole path as Finder copies it: a folder's `path(percentEncoded:)` keeps the URL's slash at the end.+ var fullPath: String {+ let path = path(percentEncoded: false)+ return path.count > 1 && path.hasSuffix("/") ? String(path.dropLast()) : path+ }}extension Int64 {diff --git a/Peel/Views/RemovalFailureAlert.swift b/Peel/Views/RemovalFailureAlert.swiftindex 43f7531c..c12b2d4b 100644--- a/Peel/Views/RemovalFailureAlert.swift+++ b/Peel/Views/RemovalFailureAlert.swift@@ -201,9 +201,9 @@ struct RemovalFailureAlert: ViewModifier {static func details(for outcome: RemovalOutcome) -> String {var lines = historyLines(outcome)- + outcome.putBackFailures.map { "\($0.url.path(percentEncoded: false))\n\($0.failure.explanation)" }+ + outcome.putBackFailures.map { "\($0.url.fullPath)\n\($0.failure.explanation)" }+ quitLines(outcome)- + outcome.failures.map { "\($0.url.path(percentEncoded: false))\n\($0.reason.explanation)" }+ + outcome.failures.map { "\($0.url.fullPath)\n\($0.reason.explanation)" }+ keptLines(outcome) + driverLines(outcome) + administratorLines(outcome)+ shellLines(outcome) { $0.formatted(.list(type: .and)) } + appManagementLines(outcome)+ privacyLines(outcome)diff --git a/Peel/Views/RemovalRow.swift b/Peel/Views/RemovalRow.swiftindex a29ca267..3684df58 100644--- a/Peel/Views/RemovalRow.swift+++ b/Peel/Views/RemovalRow.swift@@ -189,7 +189,7 @@ struct RemovalRow: View {Text(name ?? url.abbreviatedPath).lineLimit(1).truncationMode(.middle)- .help(Text(verbatim: url.path(percentEncoded: false)))+ .help(Text(verbatim: url.fullPath)).checkboxTitleLine()}@@ -253,7 +253,7 @@ struct RemovalRow: View {InfoNote(name: name ?? url.lastPathComponent,detail: explanation.characters.isEmpty ? nil : Text(explanation),- footnote: Text(verbatim: url.path(percentEncoded: false)),+ footnote: Text(verbatim: url.fullPath),caution: warning.map { Text(Self.commandsMarked($0)) },isInRow: true,opening: $isNoteOpendiff --git a/PeelTests/FullPathTests.swift b/PeelTests/FullPathTests.swiftnew file mode 100644index 00000000..33a49b29--- /dev/null+++ b/PeelTests/FullPathTests.swift@@ -0,0 +1,12 @@+import Foundation+@testable import Peel+import Testing++struct FullPathTests {+ @Test func aFolderPathEndsWithoutASlashAsFinderCopiesIt() {+ #expect(URL(filePath: "/Users/me/Library/Caches/org.example/", directoryHint: .isDirectory).fullPath+ == "/Users/me/Library/Caches/org.example")+ #expect(URL(filePath: "/Users/me/a file.txt", directoryHint: .notDirectory).fullPath == "/Users/me/a file.txt")+ #expect(URL(filePath: "/", directoryHint: .isDirectory).fullPath == "/")+ }+}