Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to Forel are documented here. Format loosely follows

### Fixed
- Date Added conditions no longer crash when reading a file's timestamp.
- Editing the number in a relative date or size condition no longer resets its unit, which could silently turn "2 Months" into "2 Days".

## [1.1.0] - 2026-10-22

Expand Down
6 changes: 4 additions & 2 deletions Sources/ForelApp/Views/RuleEditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ private struct RelativeDateValueEditor: View {
}

private var parts: (number: String, unit: String) {
let pieces = value.split(separator: " ", maxSplits: 1).map(String.init)
// omittingEmptySubsequences: false keeps "" as the number when the
// field is transiently empty mid-edit, so the unit survives keystrokes.
let pieces = value.split(separator: " ", maxSplits: 1, omittingEmptySubsequences: false).map(String.init)
let number = pieces.first?.filter(\.isNumber)
let unit = pieces.count > 1 ? pieces[1] : "days"
return ((number?.isEmpty == false ? number! : "7"), units.contains(unit) ? unit : "days")
Expand Down Expand Up @@ -714,7 +716,7 @@ private struct SizeValueEditor: View {
}

private var parts: (number: String, unit: String) {
let pieces = value.split(separator: " ", maxSplits: 1).map(String.init)
let pieces = value.split(separator: " ", maxSplits: 1, omittingEmptySubsequences: false).map(String.init)
let number = pieces.first?.filter { $0.isNumber || $0 == "." }
let rawUnit = pieces.count > 1 ? pieces[1] : "MB"
let unit = ["bytes", "KB", "MB", "GB"].contains(rawUnit) ? rawUnit : "MB"
Expand Down
Loading