Skip to content

Commit

Permalink
Fix subtle history bug, fix cutting on macOS/Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 19, 2024
1 parent bebff3c commit 0fef41a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cb/src/actions/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void history() {
// format time like 1y 2d 3h 4m 5s
auto years = std::chrono::duration_cast<std::chrono::years>(timeSince);
auto days = std::chrono::duration_cast<std::chrono::days>(timeSince - years);
auto hours = std::chrono::duration_cast<std::chrono::hours>(timeSince - days);
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(timeSince - days - hours);
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(timeSince - days - hours - minutes);
auto hours = std::chrono::duration_cast<std::chrono::hours>(timeSince - years - days);
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(timeSince - years - days - hours);
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(timeSince - years - days - hours - minutes);
if (years.count() > 0) agoMessage += std::to_string(years.count()) + "y ";
if (days.count() > 0) agoMessage += std::to_string(days.count()) + "d ";
if (hours.count() > 0) agoMessage += std::to_string(hours.count()) + "h ";
Expand Down
3 changes: 3 additions & 0 deletions src/cb/src/platforms/macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void writeToGUIClipboard(const ClipboardContent& clipboard) {
[fileArray addObject:[NSURL fileURLWithPath:@(path.c_str())]];
}
[[NSPasteboard generalPasteboard] writeObjects:fileArray];
} else {
// Write blank content
[[NSPasteboard generalPasteboard] setString:@"" forType:NSPasteboardTypeString];
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/cb/src/platforms/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ void writeToGUIClipboard(const ClipboardContent& clipboard) {
setWindowsClipboardDataPipe();
} else if (clipboard.type() == ClipboardContentType::Paths) {
setWindowsClipboardDataFiles();
} else {
// Write blank content
if (SetClipboardData(CF_UNICODETEXT, nullptr) == nullptr) {
onWindowsError("SetClipboardData");
}
}

if (CloseClipboard() == 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/cb/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,14 @@ void removeOldFiles(const std::vector<std::string>& exclusions) {
if (auto res = std::find(exclusions.begin(), exclusions.end(), fs::path(line).filename().string()); res != exclusions.end()) continue;
try {
fs::remove_all(line);
fs::remove_all(path.data / fs::path(line).filename());
} catch (const fs::filesystem_error& e) {
copying.failedItems.emplace_back(line, e.code());
}
}
files.close();
if (copying.failedItems.empty()) fs::remove(path.metadata.originals);
updateExternalClipboards(true);
}

void performAction() {
Expand Down

0 comments on commit 0fef41a

Please sign in to comment.