Fix event width bug: timed events showing half-width when all-day events exist
Timed events were incorrectly displaying at half-width when all-day events existed on the same day, even though all-day events display separately at the top of the calendar and don't visually overlap with timed events. Root cause: The overlap calculation logic was including all-day events when determining width splits for timed events. Solution: - Modified calculate_event_layout() to exclude all-day events from filtering - Updated events_overlap() to return false if either event is all-day - All-day events now don't participate in timed event width calculations Result: Timed events display at full width unless they actually overlap with other timed events, while all-day events continue to display correctly in their separate section. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1193,6 +1193,11 @@ fn calculate_event_position(event: &VEvent, date: NaiveDate, time_increment: u32
|
||||
|
||||
// Check if two events overlap in time
|
||||
fn events_overlap(event1: &VEvent, event2: &VEvent) -> bool {
|
||||
// All-day events don't overlap with timed events for width calculation purposes
|
||||
if event1.all_day || event2.all_day {
|
||||
return false;
|
||||
}
|
||||
|
||||
let start1 = event1.dtstart.with_timezone(&Local).naive_local();
|
||||
let end1 = if let Some(end) = event1.dtend {
|
||||
end.with_timezone(&Local).naive_local()
|
||||
@@ -1214,10 +1219,15 @@ fn events_overlap(event1: &VEvent, event2: &VEvent) -> bool {
|
||||
// Calculate layout columns for overlapping events
|
||||
fn calculate_event_layout(events: &[VEvent], date: NaiveDate, time_increment: u32) -> Vec<(usize, usize)> {
|
||||
|
||||
// Filter and sort events that should appear on this date
|
||||
// Filter and sort events that should appear on this date (excluding all-day events)
|
||||
let mut day_events: Vec<_> = events.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(idx, event)| {
|
||||
// Skip all-day events as they don't participate in timed event overlap calculations
|
||||
if event.all_day {
|
||||
return None;
|
||||
}
|
||||
|
||||
let (_, _, _) = calculate_event_position(event, date, time_increment);
|
||||
let local_start = event.dtstart.with_timezone(&Local);
|
||||
let event_date = local_start.date_naive();
|
||||
|
||||
Reference in New Issue
Block a user