T16 review fixes: an unknown system zone stops instead of reading as UTC, the view window refits when data shrinks, the volume profile counts narrow and flat candles whole, Fibonacci labels stay in their pane, the DOM ladder shows its tick's decimals, the tape flashes on each new trade, typed numbers reach their owner before a press, and a smaller loss than expected reads as a beat
This commit is contained in:
14 files changed
+230
-65
No files matched your search
@@ -11,9 +11,10 @@ mod zone;
|
||||
use jiff::{
|
||||
Timestamp, Zoned,
|
||||
civil::{Date, Time},
|
||||
tz::TimeZone,
|
||||
};
|
||||
|
||||
use crate::typography::format::system_zone;
|
||||
|
||||
pub use calendar::Calendar;
|
||||
pub use cron::CronEditor;
|
||||
pub use period::{MonthPicker, QuarterPicker, YearPicker};
|
||||
@@ -26,10 +27,7 @@ pub use zone::TimezoneSelect;
|
||||
|
||||
/// The system's clock in its own zone. An unknown zone stops here, not in UTC.
|
||||
pub(crate) fn zoned_now() -> Zoned {
|
||||
let zone = TimeZone::try_system().unwrap_or_else(|error| {
|
||||
panic!("the system time zone is unknown; pass a fixed date: {error}")
|
||||
});
|
||||
Timestamp::now().to_zoned(zone)
|
||||
Timestamp::now().to_zoned(system_zone("date pickers"))
|
||||
}
|
||||
|
||||
/// A day as "Sep 25, 2026".
|
||||
|
||||
+30
-12
@@ -102,6 +102,7 @@ fn commit(state: &Entity<Numeric>, next: f64, window: &mut Window, cx: &mut App)
|
||||
)
|
||||
};
|
||||
let value = settle(next, min, max, precision);
|
||||
state.update(cx, |numeric, _| numeric.value = value);
|
||||
show(&input, on_change.as_ref(), value, precision, window, cx);
|
||||
}
|
||||
|
||||
@@ -112,19 +113,36 @@ fn numeric(id: &ElementId, window: &mut Window, cx: &mut App) -> Entity<Numeric>
|
||||
.filter(|ch| ch.is_ascii_digit() || matches!(ch, '.' | ',' | '-' | format::MINUS))
|
||||
});
|
||||
let events = cx.subscribe_in(&input, window, |numeric, input, event, window, cx| {
|
||||
if !matches!(event, InputEvent::Blur | InputEvent::Submit) {
|
||||
return;
|
||||
}
|
||||
let (min, max, _, precision) = numeric.limits;
|
||||
let value = settle(numeric.current(cx), min, max, precision);
|
||||
show(
|
||||
input,
|
||||
numeric.on_change.as_ref(),
|
||||
value,
|
||||
precision,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
match event {
|
||||
InputEvent::Blur | InputEvent::Submit => {
|
||||
let value = settle(numeric.current(cx), min, max, precision);
|
||||
numeric.value = value;
|
||||
show(
|
||||
input,
|
||||
numeric.on_change.as_ref(),
|
||||
value,
|
||||
precision,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
InputEvent::Changed if input.read(cx).focus().is_focused(window) => {
|
||||
let Some(typed) = parse(input.read(cx).text()) else {
|
||||
return;
|
||||
};
|
||||
let settled = typed == settle(typed, min, max, precision);
|
||||
if typed == numeric.value || !settled {
|
||||
return;
|
||||
}
|
||||
log::info!("number input: typed {typed}");
|
||||
numeric.value = typed;
|
||||
if let Some(on_change) = numeric.on_change.clone() {
|
||||
on_change(typed, window, cx);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
Numeric {
|
||||
input,
|
||||
|
||||
@@ -183,6 +183,26 @@ fn stepping_starts_from_the_typed_number(cx: &mut TestAppContext) {
|
||||
assert_eq!(view.read_with(cx, |view, _| view.value), 21.0);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_typed_number_reaches_the_owner_before_any_blur(cx: &mut TestAppContext) {
|
||||
setup(cx);
|
||||
let (view, cx) = cx.add_window_view(|_, _| Stepped { value: 100.0 });
|
||||
cx.update(|window, _| window.focus_next());
|
||||
cx.simulate_keystrokes("cmd-a");
|
||||
cx.simulate_input("250");
|
||||
assert_eq!(
|
||||
view.read_with(cx, |view, _| view.value),
|
||||
250.0,
|
||||
"a press elsewhere reads the typed number"
|
||||
);
|
||||
cx.simulate_input(".");
|
||||
assert_eq!(
|
||||
view.read_with(cx, |view, _| view.value),
|
||||
250.0,
|
||||
"a half-typed number waits"
|
||||
);
|
||||
}
|
||||
|
||||
struct Pin {
|
||||
code: String,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user